我似乎怀念oauth2。我得到了,access_token
但没有id_token
!
我通过传递以下内容授予我的“代码”,使用以下代码来获取google access_token: https://accounts.google.com/o/oauth2/auth
$oauth2token_url = "https://accounts.google.com/o/oauth2/token";
$clienttoken_post = array(
"code" => $code,
"client_id" => $client_id,
"client_secret" => $client_secret,
"redirect_uri" => $redirect_uri,
"grant_type" => "authorization_code"
);
$curl = curl_init($oauth2token_url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $clienttoken_post);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$json_response = curl_exec($curl);
curl_close($curl);
var_dump($json_response);
一切似乎都工作,但根据谷歌的文档https://developers.google.com/accounts/docs/OAuth2Login#exchangecode我应该得到access_token, id_token, expires_in, token_type
我做除id_token
var_dump($json_response);
显示以下内容:
string(126) "{ "access_token" : "ya29.AHES6ZSGlHVW9qA23xs8bHBP578Ef8S5cntJIcPT_SHWA", "token_type" : "Bearer", "expires_in" : 3598 }
我在这里想念什么?
在令牌端点,仅当存在某些范围时才发出id_token,文档应对此进行澄清。
仅当使用了电子邮件,配置文件或OpenID Connect作用域时,才发出该消息。否则,id_token没有任何意义。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句