我要求我的客户使用他创建 google api 项目的授权 gmail 帐户访问此 URL。
https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/androidpublisher&response_type=code&access_type=offline&redirect_uri=http://www.XXXXXXXX.com/oauth2callback&client_id=XXXXXX.apps.googleusercontent.com&state=profile&approval_prompt=force
然后让他提供重定向 URL 中的 code 参数
http://www.XXXXXXXX.com/oauth2callback?code=4/jUxc2MdX0xmF-b4_I6v2SLMQMuxO.cvQLVEpcJMUXOl05ti8ZT3ZvsT9ddwI
然后我自己用以下信息发布此表格。
<form action="https://accounts.google.com/o/oauth2/token" method="post" >
<input type="hidden" name="grant_type" value="authorization_code" >
<input type="text" name="code" value="**is the one i recieved from previous step**">
<input type="hidden" name="client_id" value="XXXXXXX.apps.googleusercontent.com" >
<input type="hidden" name="client_secret" value="XXXXXXXXXXXX" >
<input type="hidden" name="redirect_uri" value="http://www.XXXXXX.com/oauth2callback" >
<input type="submit" value="Submit">
</form>
然后我收到以下错误
{
"error" : "invalid_grant"
}
当我自己生成代码 url 参数并执行下一步时。我成功收到以下回复
{
"access_token" : "XXXXXXStBkRnGyZ2mUYOLgls7QVBxOg82XhBCFo8UIT5gM",
"token_type" : "Bearer",
"expires_in" : 3600,
"refresh_token" : "XXXXXX3SEBX7F2cfrHcqJEa3KoAHYeXES6nmho"
}
但是,如果客户端生成 url 参数“代码”,那么我会看到无效的授权错误。
我的客户在英国,我在另一个国家。任何人都可以确认这是否是错误,因为客户端正在另一个国家/地区生成代码参数,而我在另一个国家/地区使用该代码?
提前致谢。