相关疑难解决方法(0)

Google OAuth 2授权 - 错误:redirect_uri_mismatch

在网站https://code.google.com/apis/console上我已经注册了我的应用程序,为我的应用设置了生成的客户端ID:客户端密钥,并尝试使用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
Run Code Online (Sandbox Code Playgroud)

这条消息是什么意思,我该如何解决?我使用gem omn​​iauth-google-oauth2.

authentication oauth-2.0 google-signin

362
推荐指数
21
解决办法
48万
查看次数

Google登录无效

我尝试在我的网站上使用Google登录,但是,它一直给我400错误.

我引用了这篇文章:https://developers.google.com/identity/sign-in/web/sign-in,我的代码非常简单:

<html>
<head>
  <title>Test Google Login</title>
  <script src="https://apis.google.com/js/platform.js" async defer></script>
  <meta name="google-signin-client_id" content="<CHANGE IT>">
  <script>
  function onSignIn(googleUser) {
    var profile = googleUser.getBasicProfile();
    console.log('ID: ' + profile.getId());
    console.log('Name: ' + profile.getName());
    console.log('Image URL: ' + profile.getImageUrl());
    console.log('Email: ' + profile.getEmail());
  }
  </script>
</head>
<body>
  <div class="g-signin2" data-onsuccess="onSignIn"></div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

当我点击登录按钮时,它弹出一个窗口,登录后,它给了我400错误,如下所示:

400. That’s an error.

The requested URL was not found on this server. That’s all we know.
Run Code Online (Sandbox Code Playgroud)

我想这是重定向问题,但我不知道如何配置它.所以我查了url它还给了我:

https://accounts.google.com/o/oauth2/auth?fetch_basic_profile=true&scope=email+profile+openid&response_type=permission&e=3100087&redirect_uri=storagerelay://http/127.0.0.1:8000?id%3Dauth867179&ss_domain=http://127.0.0.1:8000&client_id=378468243311-9dt7m9ufa9mee305j1b12815put5betb.apps.googleusercontent.com&openid.realm&hl=en&from_login=1&as=1b5f0a407ea58e11&pli=1&authuser=0
Run Code Online (Sandbox Code Playgroud)

为什么redirect_uri"storagerelay://http/127.0.0.1:8000?id%3Dauth867179"?

google-api google-oauth

5
推荐指数
1
解决办法
1万
查看次数