Google OAuth 2 授权 - 错误:redirect_uri_mismatch [英] Google OAuth 2 authorization - Error: redirect_uri_mismatch

查看:36
本文介绍了Google OAuth 2 授权 - 错误:redirect_uri_mismatch的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

On the website https://code.google.com/apis/console I have registered my application, set up generated Client ID: and Client Secret to my app and tried to log in with Google. Unfortunately, I got the error message:

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.

What does mean this message, and how can I fix it? I use the gem omniauth-google-oauth2.

推荐答案

必须在 API 控制台中注册重定向 URI(响应返回到的位置),错误表明您还没有这样做,或者没有正确完成.

The redirect URI (where the response is returned to) has to be registered in the APIs console, and the error is indicating that you haven't done that, or haven't done it correctly.

转到您项目的控制台并查看 API Access 下的内容.您应该会看到您的 客户端 ID &client secret 以及重定向 URI 列表.如果您想要的 URI 未列出,请单击编辑设置并将 URI 添加到列表中.

Go to the console for your project and look under API Access. You should see your client ID & client secret there, along with a list of redirect URIs. If the URI you want isn't listed, click edit settings and add the URI to the list.

(来自下面评价很高的评论)请注意,更新 google api 控制台和存在的更改可能需要一些时间.通常只有几分钟,但有时似乎更长.

(From a highly rated comment below) Note that updating the google api console and that change being present can take some time. Generally only a few minutes but sometimes it seems longer.

这篇关于Google OAuth 2 授权 - 错误:redirect_uri_mismatch的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆