HWIOAuthBundle Google登录Webapp的device_id和device_name [英] HWIOAuthBundle Google login device_id and device_name for a webapp

查看:152
本文介绍了HWIOAuthBundle Google登录Webapp的device_id和device_name的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Symfony2应用程序.我正在使用FOSUserBundle处理身份验证,并且最近使用此教程将其与FOSUserBundle集成: https://gist.github .com/danvbe/4476697 .

I am working on a Symfony2 app. I'm using FOSUserBundle to handle authentication and recently integrated it with FOSUserBundle using this tutorial: https://gist.github.com/danvbe/4476697 .

问题是: 我可以使用localhost上的google api登录,一切正常.

The problem is: I can login using the google api on localhost and everything works fine.

但是,当我尝试在真实服务器上登录时,会得到:

However when I try to login on a real server I get:

Error: invalid_request

device_id and device_name are required for private IP: http://<server_ip>/login/check-google

请求详细信息:

response_type=code
scope=https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile
redirect_uri=http://<server_ip>/login/check-google
client_id=<my_id>

Google文档未提及这两个参数.我试图手动发送一个请求,其中device_id为UUID,并且device_name设置为"notes".我这次得到的答复是:

Google documents don't mention these two parameters. I tried to manually send a request with device_id being a UUID and device_name set to "notes". The response I get this time is:

Error: invalid_request

Device info can be set only for native apps.

请求详细信息:

cookie_policy_enforce=false
response_type=code
device_name=notes
scope=https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile
redirect_uri=http://<server_ip>/login/check-google
device_id=4b3403665fea6
client_id=<my_id>

现在,我在做什么错了?

Now, what am I doing wrong?

推荐答案

进行Oauth或API调用时,Google不会接受本地(专用)IP地址.我的解决方法是在Windows主机文件中为本地IP添加一个条目:

Google will not accept a local (private) IP address when doing Oauth or API calls. My workaround was to add an entry in my Windows hosts file for the local IP:

\Windows\System32\drivers\etc

192.168.1.2   fakedomain.com

然后在其开发控制台中向Google注册.对于他们来说,这似乎是一个真实"的域,但仍会在您的浏览器中解析或编码为本地IP.我确信在Mac或Linux上也可以使用类似的方法.

then register it with Google in their dev console. That appears as a "real" domain to them, but will still resolve in your browser or code to the local IP. I'm sure a similar approach on Mac or Linux would also work.

这篇关于HWIOAuthBundle Google登录Webapp的device_id和device_name的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆