当您的网址包含"&"时,Google OAuth2 redirect_uri_mismatch

时间:2014-11-21 05:59:30

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

我正在使用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.

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

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

仍然没有运气......任何想法?

2 个答案:

答案 0 :(得分:1)

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

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

答案 1 :(得分:0)

您需要使用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网址编码参考

     

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

     

PHP urlencode

     

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