Google oauth2抛出“ redirect_uri_mismatch”甚至对于确切的匹配即使是错误
我的应用程序已经适用于OAuth2隐式流。我正在尝试使其用于授权代码流,但遇到了“ redirect_uri_mismatch”的错误。我不明白的一部分是“ redirect_uri”实际上与API控制台中指定的内容完全匹配。这是我运行的curl命令,其中代码
是通过google.accounts.oauth2.initcodeclient
以弹出模式获得的。
curl -X POST https://oauth2.googleapis.com/token \
--data-urlencode "code=${code}" \
--data-urlencode "redirect_uri=https://localhost:3000/api/gcode" \
--data-urlencode "client_id=${cid}" \
--data-urlencode "client_secret=${cs}" \
--data-urlencode "grant_type=authorization_code"
这给了我一个错误:
{
"error": "redirect_uri_mismatch",
"error_description": "Bad Request"
}
redirect_uri与API控制台中指定的URI完全匹配: 。
我想念什么?我已经检查了一些旧帖子,例如 /a>,但这些解决方案都不适合我的情况。
更新: 该问题似乎与该弹出式UX模式的工作方式不同于与重定向UX模式不同。 so so 也报告了同样的问题。
My app already work for OAuth2 implicit flow. I am trying to make it work for authorized code flow but I encountered an error of "redirect_uri_mismatch". The part I don't understand is that the "redirect_uri" in fact matches exactly what is specified in the API console. Here is the curl command I ran, where the code
is obtained via google.accounts.oauth2.initCodeClient
with popup mode.
curl -X POST https://oauth2.googleapis.com/token \
--data-urlencode "code=${code}" \
--data-urlencode "redirect_uri=https://localhost:3000/api/gcode" \
--data-urlencode "client_id=${cid}" \
--data-urlencode "client_secret=${cs}" \
--data-urlencode "grant_type=authorization_code"
which gives me an error:
{
"error": "redirect_uri_mismatch",
"error_description": "Bad Request"
}
The redirect_uri matches exactly one of the specified uri in the API console: .
What did I miss? I have already checked some old posts such as this one but none of the solutions works for my case.
Update:
The problem seem to be related to that popup ux mode works differently than the redirect ux mode. This SO reports the same problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论