Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HWIOAuthBundle Google login device_id and device_name for a webapp

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 .

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

Request details:

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 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.

Request details:

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?

like image 442
user3460035 Avatar asked Mar 25 '14 15:03

user3460035


2 Answers

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

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.

like image 160
Josh Diehl Avatar answered Nov 27 '22 17:11

Josh Diehl


It really looks like your using the wrong flavor of oauth. device_id is used with Devices. I would really expect you to be using the WebServer flow. You may need one of the other flows as I don't see enough detail here to judge, but they all can be found at the links.

like image 24
Les Vogel - Google DevRel Avatar answered Nov 27 '22 15:11

Les Vogel - Google DevRel