2016-08-04 64 views
0

我打电话谷歌/oauth2/v4/token符合我的要求,看起来是这样的格式:谷歌的交换令牌不返回id_token

code: 4/zxxxxxxxxxxx_Kdzxxxxxxxxn5hMzQkOoIdzLtys 
response_type: id_token 
scope: openid 
client_id: xxxxxxxxxxxxx-xxxxxxxxxxxxxxxxx.apps.googleusercontent.com 
client_secret: xxxxxxxxxxxxxxxxxxxxxxxx 
grant_type: authorization_code 

和响应是这样的:

{ 
    "access_token": "ya29.Ci81AzruWyxhmn8WKadpzPEmhCDPmQPSxHZogyd_ZIT0g-VMgzY5PZFk4i-CMe9lUw", 
    "token_type": "Bearer", 
    "expires_in": 3583 
} 

不过,我也需要id_token加入scoperesponse_type没有解决问题。我尝试了所有不同的范围和响应类型,但都没有工作。

回答

0

范围openid是不够的。例如,您应该添加范围email。 这些范围必须在授权重定向期间设置。请求访问令牌时,它们不是强制性的。

而且,当您向服务器发送请求时,不需要response_type参数。

+0

但是,如果我们不使用重定向? – Shepard

+0

要获取代码,您必须使用使用重定向的'code'响应类型。我可能''authorization_code'授权类型不是你所需要的。 –