首页 > 解决方案 > 从第 1 步获得授权代码后,单击 Exchange 授权代码

问题描述

我不确定为什么会收到此错误消息。我已经插入了 ID

POST /oauth2/v4/token HTTP/1.1
Host: www.googleapis.com
Content-length: 322
content-type: application/x-www-form-urlencoded
user-agent: google-oauth-playground

HTTP/1.1 400 错误请求内容长度:68 X-xss-protection:1;mode=block X-content-type-options: nosniff Transfer-encoding: chunked Vary: Origin, X-Origin, Referer Server: ESF -content-encoding: gzip Cache-control: private 日期: Sun, 11 Nov 2018 23:59 :34 GMT X-frame-options: SAMEORIGIN Alt-svc: quic=":443"; 马=2592000;v="44,43,39,35" 内容类型:应用程序/json;字符集=utf-8

{
  "error_description": "Bad Request", 
  "error": "invalid_grant"
}

标签: google-oauth

解决方案


Bad Request 错误发生在请求语法错误时(即当您应该发送的参数或标头丢失或包含不正确/无效的值时)。最好的选择是检查OAuth 规范,找出你在令牌请求中做错了什么。谷歌的实现可能与实际规范略有不同,但我认为查看文档后不难发现问题。

可以在此处找到授权代码授予的访问令牌请求规范。


推荐阅读