2

I have seen this page and plenty others, but all propose solution not suitable for me. I have same problem that the one in link I provided.

I am trying to use Google+ API functions, so users can log in to my page with Google account.

When I had redirect_uri to localhost:

$client->setRedirectUri("https://localhost/...");

everything worked. But then I changed it to local ip 192.168.1.10 and get error (on url https://accounts.google.com/o/oauth2/auth?response_type=code&redirect_uri=https%3A%2F%2F192.168.1.10.......)

  1. That’s an error.

Error: invalid_request

device_id and device_name are required for private IP:

I don't know what should I do. I use PHP server wrappers. I can not change etc/hosts because I am also trying my code on mobile (Android, IPAD). So, local IP is necessary, to test it on Mobile. I want to avoid setting up a test page on some real server, because testing web page on localhost is the fastest way, when still developing the page.

Community
  • 1
  • 1
Makla
  • 9,899
  • 16
  • 72
  • 142

2 Answers2

2

If you cannot change the hosts file of some of your devices, I guess your best bet is to use a local DNS server to fake a domain, just like you would do with an entry in your /etc/hosts. This answer should help you with this:

https://unix.stackexchange.com/a/64944

If you set your devices to use your computer as nameserver it should be possible to spoof a domain and use this domain for testing oauth2 authentication.

Here is some more information about this error: http://developers.blog.box.com/2012/12/19/going-beyond-oauth2-byod-in-the-enterprise/

device_id and devive_name are mentioned in the specs as well: https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-31#section-3.2.1

Community
  • 1
  • 1
jeverling
  • 2,004
  • 1
  • 20
  • 21
2

Google does not accept a local (private) IP address when doing Oauth or API calls. Instead, you can add an entry in your Windows hosts file for the local IP: \Windows\System32\drivers\etc

192.168.1.10 fakedomain.com

Then use fakedomain.com to callback URI in google instead of your local IP address.

Finally browse the service with http://fakedomain.com