Oauth 2.0 无法获取访问令牌google drive sdk
我想在我的应用程序中使用GoogleDriveAPI,这就是为什么我在安装的应用程序中使用OAuth2.0。但我有一个问题-我无法获得访问令牌。首先,我使用以下请求成功获取授权代码:Oauth 2.0 无法获取访问令牌google drive sdk,oauth-2.0,google-drive-api,Oauth 2.0,Google Drive Api,我想在我的应用程序中使用GoogleDriveAPI,这就是为什么我在安装的应用程序中使用OAuth2.0。但我有一个问题-我无法获得访问令牌。首先,我使用以下请求成功获取授权代码: https://accounts.google.com/o/oauth2/auth? scope=https://www.googleapis.com/auth/drive.file& redirect_uri=[my redirect_uri from from Developers Cons
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
然后,我尝试使用收到的授权码,通过以下请求获取访问令牌:
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。你能告诉我有什么问题吗
跟踪http请求
去OAuth2游乐场做同样的事情
找出区别
可能是您没有对参数进行URL编码