2012-06-28 483 views
1

我試圖得到一個訪問令牌使用谷歌的Web API播放,但它不會工作,並且不會給出一個有用的錯誤消息,Google不提供支持。谷歌API授權碼/訪問令牌生成:錯誤400:錯誤的請求

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

Client ID for web applications 
Client ID: 37625491467222.apps.googleusercontent.com 
Email address: [email protected] 
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

[根@ 308321〜]#貓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.k izbit.com%2Foauth2callback

[[email protected] ~]# 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. 

我知道你不應該給了鑰匙,但它並不重要,因爲這是行不通的!

刷新令牌也不起作用。

不編碼的文件無法正常工作或:

[[email protected] ~]# 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 

[[email protected] ~]# 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. 

回答

0

我不知道我是如何解決這個。我可能做的一些可能的事情:

  1. 使用來自與網頁授權請求相同的IP的訪問令牌請求來獲取代碼。
  2. 使用wget -dSO- --post-file調試。
  3. 網頁授權後很快訪問令牌請求。也許代碼只能持續10米?
  4. 添加更多的IP地址在谷歌API控制檯JavaScript源。
  5. 重新URL編碼POST文件和去掉所有尾隨換行。

無論如何,一旦我獲得訪問令牌和所有重要的刷新標記,我就很好。

相關問題