无法获取访问令牌谷歌云端硬盘 SDK



我想在我的应用程序中使用 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。你能告诉我可能有什么问题吗?

  1. 跟踪 http 请求
  2. 转到OAuth2游乐场并执行相同的操作
  3. 发现差异

可能是你没有对参数进行编码

相关内容

最新更新