Google OAuth2授权OAuth令牌错误:redirect_uri_mismatch

Cac*_*ing 20 oauth-2.0 google-oauth

我正在根据此网页创建和授权OAuth令牌:https://code.google.com/p/google-mail-oauth2-tools/wiki/OAuth2DotPyRunThrough

但是我收到了这个错误:redirect_uri_mismatch.

The redirect URI in the request: urn:ietf:wg:oauth:2.0:oob did not match a registered redirect URI
from_login=1
cookie_policy_enforce=false
scope=https://mail.google.com/
response_type=code
access_type=online
redirect_uri=urn:ietf:wg:oauth:2.0:oob
as=-80019291b2cb8ed
display=page
pli=1
client_id=......
authuser=0
hl=en
Run Code Online (Sandbox Code Playgroud)

我认为这可能会有所帮助:Google OAuth 2授权 - 错误:redirect_uri_mismatch

但是当我尝试将重定向url注册到我的控制台时,我被告知该url无效.

ora*_*ecz 48

redirect_uri(urn:ietf:wg:oauth:2.0:oob)仅适用于为已安装的应用程序生成的那些Google客户端ID .您可以转到控制台并创建此类型的新客户端ID.

  • DOH.使用为Web应用程序创建的.我希望我生命的最后4个小时回来! (4认同)
  • 我找不到为已安装的应用程序创建 OAuth2 密钥的选项。 (2认同)

Mik*_*nov 30

如果您使用的是Google+ javascript按钮(使用网络应用程序),则必须使用postmessage而不是实际的URI.我花了差不多一整天才弄明白这一点,因为谷歌的文档由于某种原因并没有明确表现出来.


Guv*_*urt 9

对于我的网络应用程序,我通过写作纠正了我的错

instead of : http://localhost:11472/authorize/
type :      http://localhost/authorize/
Run Code Online (Sandbox Code Playgroud)


Kat*_*hir 7

当您在app上注册https://code.google.com/apis/console并创建客户端ID时,您有机会指定一个或多个重定向URI.redirect_uri您的身份验证URI上的参数值必须与其中一个完全匹配.


小智 7

请注意,令牌请求的'redirect_uri'值必须与授权请求的'redirect_uri'值相同.


小智 5

为此浪费了 4 或 5 个小时...使用“postmessage”作为参数值,而不是真正的重定向 Uri...

$client->setRedirectUri('postmessage');
Run Code Online (Sandbox Code Playgroud)