Google API验证码/访问令牌生成:错误400:错误请求

时间:2012-06-28 05:36:31

标签: android oauth google-play

我试图获取访问令牌以使用Google网络Play API,但它无法正常工作,并且无法提供有用的错误消息,Google也没有这样做。提供一点支持。

https://developers.google.com/android-publisher/authorization

Client ID for web applications
Client ID:  37625491467222.apps.googleusercontent.com
Email address:  37625491467222@developer.gserviceaccount.com
Client secret:  XB5gwFt8w29Fs34540gr9urEGEmUHCLI
Redirect URIs:  http://www.kizbit.com/oauth2callback
JavaScript origins: http://www.kizbit.com

刷新令牌: http://www.kizbit.com/oauth2callback?code=4/IAoP7JxYfe82KsuUwQRWQw2na_vreOM.MtjvGJqCG3IYshQV0ieZDArkfr1icAI

[root @ 308321~] #cat authcode.txt grant_type = authorization_code&安培;代码= 4%2FIAoP7JxYfe82KsuUwQRWQw2na_vreOM.MtjvGJqCG3IYshQV0ieZDArkfr1icAI&安培; CLIENT_ID = 37625491467222.apps.googleusercontent.com&安培; client_secret = XB5gwFt8w29Fs34540gr9urEGEmUHCLI&安培; REDIRECT_URI = HTTP%3A%2F%2Fwww.kizbit.com%2Foauth2callback

[root@308321 ~]# wget -S --post-file=authcode.txt  https://accounts.google.com/o/oauth2/token
--2012-06-28 01:08:37--  https://accounts.google.com/o/oauth2/token
Resolving accounts.google.com... 2001:4860:b007::54, 74.125.142.84
Connecting to accounts.google.com|2001:4860:b007::54|:443... connected.
HTTP request sent, awaiting response...
  HTTP/1.0 400 Bad Request
  Cache-Control: no-cache, no-store, max-age=0, must-revalidate
  Pragma: no-cache
  Expires: Fri, 01 Jan 1990 00:00:00 GMT
  Date: Thu, 28 Jun 2012 05:08:40 GMT
  Content-Type: application/json
  X-Content-Type-Options: nosniff
  X-Frame-Options: SAMEORIGIN
  X-XSS-Protection: 1; mode=block
  Server: GSE
2012-06-28 01:08:
37 ERROR 400: Bad Request.

我知道你不应该发出钥匙,但这并不重要,因为它不起作用!

刷新令牌也不起作用。

不编码文件也不起作用:

[root@308321 ~]# cat authcode2.txt
grant_type=authorization_code
code=4/IAoP7JxYfe82KsuUwQRWQw2na_vreOM.MtjvGJqCG3IYshQV0ieZDArkfr1icAI
client_id=37625491467222.apps.googleusercontent.com
client_secret=XB5gwFt8w29Fs34540gr9urEGEmUHCLI
redirect_uri=http://www.kizbit.com/oauth2callback

[root@308321 ~]# wget -S --post-file=authcode2.txt  https://accounts.google.com/o/oauth2/token
--2012-06-28 01:33:44--  https://accounts.google.com/o/oauth2/token
Resolving accounts.google.com... 2001:4860:b007::54, 74.125.142.84
Connecting to accounts.google.com|2001:4860:b007::54|:443... connected.
HTTP request sent, awaiting response...
  HTTP/1.0 400 Bad Request
  Cache-Control: no-cache, no-store, max-age=0, must-revalidate
  Pragma: no-cache
  Expires: Fri, 01 Jan 1990 00:00:00 GMT
  Date: Thu, 28 Jun 2012 05:33:47 GMT
  Content-Type: application/json
  X-Content-Type-Options: nosniff
  X-Frame-Options: SAMEORIGIN
  X-XSS-Protection: 1; mode=block
  Server: GSE
2012-06-28 01:33:44 ERROR 400: Bad Request.

1 个答案:

答案 0 :(得分:0)

我不知道我是怎么解决这个问题的。我可能做过的一些事情:

  1. 从与网页授权请求相同的IP生成访问令牌请求以获取代码。
  2. 使用wget -dSO- --post-file进行调试。
  3. 在网页授权后非常快速地发出访问令牌请求。也许代码只能持续10米?
  4. 在Google API控制台中为Javascript来源添加更多IP。
  5. 对POST文件进行重新U​​RL编码,并删除所有尾随换行符。
  6. 无论如何,一旦我获得了访问令牌和非常重要的刷新令牌,我就很好。