【问题标题】:Google OAuth2 redirect_uri_mismatch when your url contains "&"当您的网址包含“&”时,Google OAuth2 redirect_uri_mismatch
【发布时间】:2015-01-19 05:24:46
【问题描述】:

我正在使用 PHP HybridAuth 库并集成了 oauth2 支持,所有提供商(例如 Yahoo、MSN 和 Facebook 都可以使用,但 Google 除外)显示

The redirect URI in the request: 
https://www.example.com/auth?action=callback&hauth.done=Google did not match a registered redirect URI.

我的重定向 url 是:https://www.example.com/auth?action=callback&hauth.done=Google,我已经添加了两个 url,看看我是否可以解决它们的无意义转义限制,例如

https://www.example.com/auth?action=callback&hauth.done=Google
https://www.example.com/auth?action=callback&hauth.done=Google 

还是没有运气...有什么想法吗?

【问题讨论】:

  • 尝试添加页面? example.com/auth/…
  • 是因为 & 签名还是因为您使用的 https 页面没有经过认证。使用受信任的证书检查其他一些 URL

标签: oauth oauth-2.0 google-api google-oauth hybridauth


【解决方案1】:

你需要使用 PHP urlencode 函数。

urlencode — URL-encodes string
(PHP 4, PHP 5)

string urlencode ( string $str )

此函数在对要在 URL 的查询部分中使用的字符串进行编码时很方便,作为将变量传递到下一页的便捷方式。

例子:

$encoded_url = urlencode("https://www.example.com/auth?action=callback&hauth.done=Google");

更多信息:

HTML URL 编码参考

http://www.w3schools.com/tags/ref_urlencode.asp

PHP 网址代码

http://php.net/manual/en/function.urlencode.php

【讨论】:

    【解决方案2】:

    只是一个假设,尝试urlencode()'ing url,

    $url = "https://www.example.com/auth?action=callback" . urlencode("&hauth.done=Google");
    

    【讨论】:

      猜你喜欢
      • 2014-06-12
      • 2021-06-22
      • 2014-07-01
      • 2012-04-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-12
      • 2020-06-13
      相关资源
      最近更新 更多