2017-03-04 7 views
0

laravelを使用してサーバーとクライアントの両方のアプリケーションを作成すると、サーバーアプリケーションからクライアントアプリケーションにもデータにアクセスできます。しかし今、私はcodeigniterを使って別のクライアントアプリケーションを作りたいと思っています。認可は、コールバックメソッドを除いて機能します。どうすればこのコードを変換できますか?Laravelパスポート「トークンにアクセスするための認証コードの変換」codeigniterのコード

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

とにかく、私はすでにそれを修正しました。

  1. "guzzlehttp /がつがつ食う" 追加: "〜6.0" composer.jsonで
  2. 作曲更新
  3. コールバックメソッドのコードを実行している

    $ HTTP =新しい\ GuzzleHttp \クライアント。

    $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)); 
    
関連する問題