我正在使用Google OAuth连接到信息中心,问题是当回调的GET
&scope
参数包含类似“https://www.googleapis.com/auth/userinfo.profile”的网址时,主机会返回错误403。
因此,经过多次研究,我发现的唯一解决方案是从网址中删除范围。
我想更改回调网址:
https://msite.com/?code=xxx&scope=email%20profile%20https://www.googleapis.com/auth/userinfo.profile%20https://www.googleapis.com/auth/userinfo.email
对此
https://msite.com/?code=xxx&scope=true
这是我的基本htaccess
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /index.php?a=$1 [QSA,L]
你可以用这个:
RewriteEngine on
RewriteCond %{THE_REQUEST} /\?code=([^&]+)&scope=email.+ [NC]
RewriteRule ^$ /?code=%1&scope=true [L,R=301]
这将重定向您的网址
/?code=Sometext&scope=emailSometext
至
/?code=Sometext&scope=true