向Google gmail API发出令牌请求时,请求400错误

丁字裤

我遵循此文档提出令牌请求https://developers.google.com/identity/protocols/OAuth2InstalledApp

第一步,它工作正常。我可以获得验证码。在第二步中,我遇到了400错误请求的问题。我已经为这个问题找到答案了2天,但是我无法解决问题。我将所有属性都设置为文档,但是没关系:

POST /oauth2/v3/token HTTP/1.1
Host: www.googleapis.com
Content-Type: application/x-www-form-urlencoded

code=4/v6xr77ewYqhvHSyW6UJ1w7jKwAzu&
client_id=8819981768.apps.googleusercontent.com&
client_secret=your_client_secret&
redirect_uri=https://oauth2-login-demo.appspot.com/code&
grant_type=authorization_code

这是我的代码:

    postData.Clear()
    ' code is the authentication code in the first request
    postData.Add("code=" + code)
    postData.Add("client_id=###############.apps.googleusercontent.com")
    postData.Add("client_secrect=####################")
    postData.Add("redirect_uri=urn:ietf:wg:oauth:2.0:oob")
    postData.Add("grant_type=authorization_code")

    Dim data As String = String.Join("&", postData.ToArray())
    Dim request As HttpWebRequest = HttpWebRequest.Create("https://www.googleapis.com/oauth2/v3/token")
    Dim byteData() As Byte = Encoding.UTF8.GetBytes(data)

    request.Host = "www.googleapis.com"
    request.Method = WebRequestMethods.Http.Post
    request.ProtocolVersion = HttpVersion.Version11
    request.ContentType = "application/x-www-form-urlencoded"
    request.ContentLength = byteData.Length

    Dim dataStream As Stream = request.GetRequestStream()
    dataStream.Write(byteData, 0, byteData.Length)
    dataStream.Close()        

    Dim response As HttpWebResponse = request.GetResponse()
    Dim reader As Stream = response.GetResponseStream()
    response.Close()

感谢您的回答!

丁字裤

我刚刚发现了一个错误。这是一个愚蠢的错误。我输入了client_secret的client_secrect接口。我无法相信我花了2天的时间来解决此错误。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

我可以向Gmail / Google发出多少个请求?

来自分类Dev

在Express.js上使用Axios向Spotify API发出POST请求时出现错误400

来自分类Dev

带有服务凭证的 Google Gmail API 请求使用 Java SDK 返回 400

来自分类Dev

在Swift中向本地服务器发出发布请求时出现400错误

来自分类Dev

向Google Contacts REST API发出HTTP GET请求时如何使用API密钥

来自分类Dev

节点js,向Google api发出https发布请求

来自分类Dev

向Google表单发出POST请求

来自分类Dev

向 Google 应用引擎发出 GET 请求

来自分类Dev

当我向 api 服务器发出 post 请求时收到 404 错误

来自分类Dev

Gmail API - 海量请求

来自分类Dev

当我通过 UI 向 api 端点发出 GET/POST 请求时,如何发送我的 JWT 令牌?

来自分类Dev

向Pixellena Lux API请求时发出UnhandledPromiseRejectionWarning警告

来自分类Dev

ECONNRREFUSED 使用 Nodejs 向 API 发出获取请求时出错

来自分类Dev

Google的GMail API下载附件

来自分类Dev

尝试使用Google Gmail API时出错

来自分类Dev

使用Indy HTTP的Delphi Google oauth2令牌请求获得400错误请求

来自分类Dev

$ http提供程序向Github API发出外部请求,但不向Google Map API发出请求

来自分类Dev

向 cURL 发出请求时出错

来自分类Dev

使用 Nodejs 向 Google API Dialogflow 请求时出现错误 ENOTFOUND

来自分类Dev

尝试向API发出多个请求时出现TypeScript可观察到的错误(Angular,TypeScript,RxJS)

来自分类Dev

重复规则错误400错误的请求-Google Api日历

来自分类Dev

使用 python 3.6 向带有令牌的 API 发出我的第一个请求

来自分类Dev

如何从getStaticProps向API路由发出请求

来自分类Dev

停用Gmail API请求缓存

来自分类Dev

如何从Google Cloud获取OAuth2身份验证令牌(代号为1),然后使用它向云自然语言API发出请求

来自分类Dev

向Google Maps Engine发出的请求中缺少什么?

来自分类Dev

如何从Google脚本向BigQuery发出正确的HTTP请求

来自分类Dev

Python-如何使用请求向API发出PATCH请求

来自分类Dev

HttpError 400错误请求-Google Admin Directory API(Python)

Related 相关文章

  1. 1

    我可以向Gmail / Google发出多少个请求?

  2. 2

    在Express.js上使用Axios向Spotify API发出POST请求时出现错误400

  3. 3

    带有服务凭证的 Google Gmail API 请求使用 Java SDK 返回 400

  4. 4

    在Swift中向本地服务器发出发布请求时出现400错误

  5. 5

    向Google Contacts REST API发出HTTP GET请求时如何使用API密钥

  6. 6

    节点js,向Google api发出https发布请求

  7. 7

    向Google表单发出POST请求

  8. 8

    向 Google 应用引擎发出 GET 请求

  9. 9

    当我向 api 服务器发出 post 请求时收到 404 错误

  10. 10

    Gmail API - 海量请求

  11. 11

    当我通过 UI 向 api 端点发出 GET/POST 请求时,如何发送我的 JWT 令牌?

  12. 12

    向Pixellena Lux API请求时发出UnhandledPromiseRejectionWarning警告

  13. 13

    ECONNRREFUSED 使用 Nodejs 向 API 发出获取请求时出错

  14. 14

    Google的GMail API下载附件

  15. 15

    尝试使用Google Gmail API时出错

  16. 16

    使用Indy HTTP的Delphi Google oauth2令牌请求获得400错误请求

  17. 17

    $ http提供程序向Github API发出外部请求,但不向Google Map API发出请求

  18. 18

    向 cURL 发出请求时出错

  19. 19

    使用 Nodejs 向 Google API Dialogflow 请求时出现错误 ENOTFOUND

  20. 20

    尝试向API发出多个请求时出现TypeScript可观察到的错误(Angular,TypeScript,RxJS)

  21. 21

    重复规则错误400错误的请求-Google Api日历

  22. 22

    使用 python 3.6 向带有令牌的 API 发出我的第一个请求

  23. 23

    如何从getStaticProps向API路由发出请求

  24. 24

    停用Gmail API请求缓存

  25. 25

    如何从Google Cloud获取OAuth2身份验证令牌(代号为1),然后使用它向云自然语言API发出请求

  26. 26

    向Google Maps Engine发出的请求中缺少什么?

  27. 27

    如何从Google脚本向BigQuery发出正确的HTTP请求

  28. 28

    Python-如何使用请求向API发出PATCH请求

  29. 29

    HttpError 400错误请求-Google Admin Directory API(Python)

热门标签

归档