在网站上https://code.google.com/apis/console我已经注册了我的应用程序,为我的应用程序设置了生成的客户端 ID: 和客户端 key ,并尝试使用 Google 登录。 不幸的是,我收到了错误消息:
Error: redirect_uri_mismatch
The redirect URI in the request: http://127.0.0.1:3000/auth/google_oauth2/callback did not match a registered redirect URI
scope=https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email
response_type=code
redirect_uri=http://127.0.0.1:3000/auth/google_oauth2/callback
access_type=offline
approval_prompt=force
client_id=generated_id
此消息是什么意思?我该如何解决它? 我使用 gem omniauth-google-oauth2。
最佳答案
重定向 URI(返回响应的位置)必须在 API 控制台中注册,错误表明您没有这样做,或者没有正确完成。
转到您的项目的控制台并在“API 访问”下查看。您应该在那里看到您的客户端 ID
和客户端 key
,以及重定向 URI 列表。如果所需的 URI 未列出,请单击“编辑设置”并将 URI 添加到列表中。
编辑:(来自下面评价很高的评论)请注意,更新 google api 控制台以及当前的更改可能需要一些时间。一般只有几分钟,但有时看起来更长。
关于authentication - Google OAuth 2 授权 - 错误 : redirect_uri_mismatch,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11485271/