2014-02-28 65 views
1

我想在我的应用程序中使用Google驱动器API,这就是为什么我使用OAuth 2.0安装应用程序。但我有一个问题 - 我无法获得访问令牌。无法获取访问令牌谷歌驱动器sdk

https://accounts.google.com/o/oauth2/auth? 
    scope=https://www.googleapis.com/auth/drive.file& 
    redirect_uri=[my redirect_uri from from Developers Console]& 
    response_type=code& 
    client_id=[My client ID for native application from Developers Console] 

然后我尝试使用收到的授权码使用以下请求获得一个访问令牌:起初我用下面的请求成功获取授权码

POST /o/oauth2/token HTTP/1.1 
    Host: accounts.google.com 
    Content-Type: application/x-www-form-urlencoded 

    code={My uthorization code}& 
    client_id=[My client Id]& 
    client_secret=[My clien secret]& 
    redirect_uri=[my redirect_uri from from Developers Console]& 
    grant_type=authorization_code 

所有时间服务器返回400你能告诉我可能是什么问题吗?

回答

0
  1. 跟踪的HTTP请求
  2. 进入到OAuth2游乐场,做同样的
  3. 现货的差异

这可能是因为你没有URL编码的PARAMS

相关问题