我想在我的应用程序中使用Google驱动器api,这就是我为安装的应用程序使用OAuth 2.0的原因。但我有一个问题 - 我无法获得访问令牌。首先,我使用以下请求成功获取授权码:
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 :(得分:0)
可能是你没有对参数进行urlencoding