首页 > 解决方案 > Google Oauth2.0 端点返回 404 错误

问题描述

我正在尝试使用 http 请求获取访问令牌。根据 Oauth 指南: https ://developers.google.com/identity/protocols/oauth2/web-server#incrementalAuth 用于交换授权码以访问令牌的端点是,https://oauth2.googleapis.com/token但它给出了一个页面找不到 HTTP 404 错误这是我的完整网址(我已经替换了代码、客户端 ID 和机密)

https://oauth2.googleapis.com/token?
code=xxxxx&
client_id=xxxxx&
client_secret=xxxxx&
redirect_uri=http://localhost&
grant_type=authorization_code

标签: oauth-2.0google-oauth

解决方案


看起来您正在将必填字段作为查询参数传递,但您需要将它们放在帖子正文中并向https://oauth2.googleapis.com/token发送 HTTPS POST 请求。您可以在您所指的文档中进一步找到此信息:https ://developers.google.com/identity/protocols/oauth2/web-server#httprest_7 。


推荐阅读