授权设备访问时没有刷新令牌
No refresh token while authorizing Device Access
我能够通过 Partner Connections Manager 成功授权用户,但是当我使用我的授权代码从 https://www.googleapis.com/oauth2/v4/token
请求令牌时,我没有在响应中收到 refresh_token
,只有access_token
存在:
{
access_token: 'my-access-token',
expires_in: 3599,
scope: 'https://www.googleapis.com/auth/sdm.service',
token_type: 'Bearer'
}
确保在您的合作伙伴连接管理器 (PCM) URL 中指定 access_type=offline
。省略它假定 access_type=online
,它不提供刷新令牌。
例如,PCM URL 应该看起来像这样,其中 access_type=offline
:
https://nestservices.google.com/partnerconnections/project-id/auth?
redirect_uri=my-redirect-uri&
access_type=offline&
prompt=consent&
client_id=my-client-id&
response_type=code&
scope=https://www.googleapis.com/auth/sdm.service
然后,来自 https://www.googleapis.com/oauth2/v4/token
的后续令牌响应应该符合您的预期:
{
"access_token": "my-access-token",
"expires_in": 3599,
"refresh_token": "my-refresh-token",
"scope": "https://www.googleapis.com/auth/sdm.service",
"token_type": "Bearer"
}
有关详细信息,请参阅设备访问站点上的Authorize an Account。
我能够通过 Partner Connections Manager 成功授权用户,但是当我使用我的授权代码从 https://www.googleapis.com/oauth2/v4/token
请求令牌时,我没有在响应中收到 refresh_token
,只有access_token
存在:
{
access_token: 'my-access-token',
expires_in: 3599,
scope: 'https://www.googleapis.com/auth/sdm.service',
token_type: 'Bearer'
}
确保在您的合作伙伴连接管理器 (PCM) URL 中指定 access_type=offline
。省略它假定 access_type=online
,它不提供刷新令牌。
例如,PCM URL 应该看起来像这样,其中 access_type=offline
:
https://nestservices.google.com/partnerconnections/project-id/auth?
redirect_uri=my-redirect-uri&
access_type=offline&
prompt=consent&
client_id=my-client-id&
response_type=code&
scope=https://www.googleapis.com/auth/sdm.service
然后,来自 https://www.googleapis.com/oauth2/v4/token
的后续令牌响应应该符合您的预期:
{
"access_token": "my-access-token",
"expires_in": 3599,
"refresh_token": "my-refresh-token",
"scope": "https://www.googleapis.com/auth/sdm.service",
"token_type": "Bearer"
}
有关详细信息,请参阅设备访问站点上的Authorize an Account。