我在网站上启用了Google登录选项,我从这里获得UserInfo和电子邮件。我正在使用适用于PHP的Google API客户端库。
我将重定向网址设置为
$client->setRedirectUri('http://login.example.com/authenticate/redirect_back');
在Google Developers Console中也是如此。因此,用户登录成功后,Google重定向回
现在我的问题是“如果有人有意创建code=4/xzzzz
怎么办?”因为谷歌公开展示了它的重定向位置(见截图链接|抱歉,我不能发布< 10声誉)。
我尝试使用虚拟值进行身份验证。但在获取UserInfo时,invalid_grant
会引发致命错误。谷歌重定向后,有没有办法验证代码值?
答案 0 :(得分:1)
我猜你不需要保护Google重定向网址。
因为认证流程清楚地表明了这一点,
once user grants the basic permission to access their data, user is redirected back to your website with Authentication code. The code is used to obtain Access Token, using Access Token the application can access current user data from Google, which could be used to register and login the user.
因此,如果用户尝试使用任意代码点击回调网址,Google将无法对用户进行身份验证,并为您提供User Info
和email
。因此,您将无法注册/登录用户。