获取访问令牌Google Play Android Developer API

问题描述 投票:0回答:1

我使用了这个主题的代码:Unable to get the subscription information from Google Play Android Developer API

我可以从uri获取刷新令牌

https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/androidpublisher&response_type=code&access_type=offline&redirect_uri=REDIRECT_URI&client_id=CLIENT_ID

我打电话给qazxsw poi,答案是:

getRefreshToken(token from URI)

有了这个访问令牌,我可以获得有关我的谷歌Android开发者帐户的信息。

问题是访问令牌在1小时后到期,我无法重新生成它。我试着打电话给{ "access_token" : "ya29.1.AADtN_XSr_9GwIybDh0fT5kt487DGYEed2sTzugp_MDOLEJAiMOTY3o17HwnvA7BIgP6", "token_type" : "Bearer", "expires_in" : 3407 } ,anwser是:

getAccessToken(token from uri)

我在JAVA的谷歌应用引擎服务器上使用此代码。

如果有人用com.google.api.client.auth.oauth2记录此方法可能会很棒。

android google-app-engine oauth-2.0 in-app-purchase google-api-java-client
1个回答
2
投票

获得刷新令牌时的默认第一响应是:

{
    "error" : "invalid_grant"
}

每个下一个响应返回:

{ 
"access_token" : "****", 
"token_type" : "Bearer", 
"expires_in" : 3600,
"refresh_token" : "****" 
}

您需要从谷歌帐户中删除oAuth或在请求强制获取刷新令牌时使用“approval_prompt = force”。

© www.soinside.com 2019 - 2024. All rights reserved.