2017-03-04 4 views
0

laravel을 사용하여 서버 및 클라이언트 응용 프로그램을 모두 성공적으로 만들었으므로 서버 응용 프로그램에서 클라이언트 응용 프로그램으로 데이터에 액세스 할 수도 있습니다. 하지만 이제 codeigniter를 사용하여 다른 클라이언트 응용 프로그램을 만들고 싶습니다. 권한 부여는 콜백 메소드를 제외하고 작동합니다. 그렇다면 어떻게이 코드를 변환 할 수 있습니까?Laravel 패스포트 "코드에 액세스 할 수있는 인증 코드 변환"코드 번호

Route::get('/callback', function (Request $request) { 
    $http = new GuzzleHttp\Client; 

    $response = $http->post('http://your-app.com/oauth/token', [ 
     'form_params' => [ 
      'grant_type' => 'authorization_code', 
      'client_id' => 'client-id', 
      'client_secret' => 'client-secret', 
      'redirect_uri' => 'http://example.com/callback', 
      'code' => $request->code, 
     ], 
    ]); 

    return json_decode((string) $response->getBody(), true); 
}); 

into CodeIgniter 2?

감사합니다.

답변

1

어쨌든, 이미 고칠 수 있습니다. "guzzlehttp/폭식"추가

  1. : "~ 6.0"composer.json의 작곡가 업데이트를
  2. 콜백 메소드 코드

    $ HTTP = 새로운 \ GuzzleHttp \ 클라이언트를 실행

  3. ;

    $response = $http->post('http://localhost:8000/oauth/token', [ 
        'form_params' => [ 
         'grant_type' => 'authorization_code', 
         'client_id' => '3', 
         'client_secret' => 'client-secret-from-db', 
         'redirect_uri' => 'ci-client-app/callback', 
         'code' => $this->input->get('code', TRUE) 
        ], 
    ]); 
    
    echo '<pre>', print_r(json_decode((string) $response->getBody(), true));