在https://code.google.com/apis/console网站上,我已经注册了我的应用程序,设置生成的客户端ID:和客户端秘密到我的应用程序,并尝试登录谷歌。 不幸的是,我收到了错误信息:

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

这条信息是什么意思,我该如何修复它? 我使用宝石omniauth-google-oauth2。


当前回答

就我而言,我补充道

https://websitename.com/sociallogin/social/callback/?hauth.done=Google

在授权重定向uri部分,它为我工作

其他回答

更新—>适用于Android应用程序

只使用:

http://localhost/oauth2callback

如果你处理自己的逻辑没有重定向链接的web应用程序

在我的例子中,重置secret ('reset secret'-按钮)就成功了。

重要补充:我发现在跨客户端服务器认证流程中,当你从Web SDK接收到serverAuthCode时,你应该使用“postmessage”,当你从Android或iOS SDK接收到serverAuthCode时,将redirect_uri设置为空。

我的问题是,我在地址栏中有http://localhost:3000/,在console.developers.google.com中有http://127.0.0.1:3000/

我在控制台中有两个请求uri, http://xxxxx/client/api/spreadsheet/authredirect和http://localhost。

我尝试了这个问题的所有回答,并确认没有一个是我的问题。

我从控制台删除了localhost,更新了client_secret。Json在我的项目中,不匹配错误消失了。