2017-06-06 17 views
1

Guzzle3からGuzzle6に移動しています。私は、Guzzle3で正常に機能しているAzure Management APIを認証してアクセスするプロセスを作成しました。しかし、私はそれをGuzzle6で動作させる方法を理解することができません。その目的は、Azure Management APIへの後続のリクエストで使用されるアクセストークンを取得することです。Guzzle6(エラー:AADSTS90014)を使用してAzureトークンを取得するときに問題が発生する

オリジナルコード:

$client = new Guzzle\Http\Client(); 
$request = $client->post("https://login.microsoftonline.com/{$tenant_id}/oauth2/token", 
    Array(
     'Accept' => 'application/json', 
    ), 
    Array(
     'grant_type' => 'client_credentials', 
     'client_id'  => $application_id, 
     'client_secret' => $application_secret, 
     'resource'  => 'https://management.core.windows.net/', 
    ) 
); 

$response = $request->send(); 
$body = $response->getBody(true); 

私が働いている新しいコード:私は運と非常に多くのバリエーションを試してみた

$client = new GuzzleHttp\Client(); 
$response = $client->request(
    'POST', 
    "https://login.microsoftonline.com/{$tenant_id}/oauth2/token", 
    Array(
     GuzzleHttp\RequestOptions::JSON => Array(
      'grant_type' => 'client_credentials', 
      'client_id'  => $application_id, 
      'client_secret' => $application_secret, 
      'resource'  => 'https://management.core.windows.net/', 
     ) 
    ) 
); 

。誰もが提供できる洞察に感謝します。

ありがとうございます!

答えて

1

ここに投稿すると、私の考えを導くのに役立ちました。私はそれを働かせることができました。同じボートの他の誰でも、私が思いついた解決策は次のとおりです。

$client = new GuzzleHttp\Client(); 
$response = $client->request(
    'POST', 
    "https://login.microsoftonline.com/{$tenant_id}/oauth2/token", 
    Array(
     'form_params' => Array(
      'grant_type' => 'client_credentials', 
      'client_id'  => $application_id, 
      'client_secret' => $application_secret, 
      'resource'  => 'https://management.core.windows.net/', 
     ) 
    ) 
); 
関連する問題