1

我正在尝试获取访问令牌以使用 Google Web 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&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.
4

1 回答 1

0

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

  1. 从与网页授权请求相同的 IP 发出访问令牌请求以获取代码。
  2. 用于wget -dSO- --post-file调试。
  3. 在网页授权后非常快速地发出访问令牌请求。也许代码只持续10m?
  4. 在 Google API 控制台中向 Javascript 源添加更多 IP。
  5. 重新 URL 对 POST 文件进行编码并去除任何尾随的换行符。

无论如何,一旦我获得了访问令牌和非常重要的刷新令牌,我就很好了。

于 2012-07-04T22:27:14.363 回答