Can a public IP address be used as Google OAuth redirect URI?

Google Oauth

Google Oauth Problem Overview


I'm trying to set a web service that needs the user's Google Latitude info, so I'm using Google OAuth to get the user authorization stuff.

However, when trying to set the redirection URI in the Google APIs Console for a web application client ID I get a message error if I try to set it to 'http://PUBLIC_IP/'.

I need to test it with non local users (thus localhost can't be used), so I would like to know if having a web domain is mandatory in order to use Google's OAuth. If not, how can I solve this issue?

Google Oauth Solutions


Solution 1 - Google Oauth

This is not currently supported. I filed a feature request and will update on progress.

Solution 2 - Google Oauth

You can use xip.io to work around it.

For example: '192.168.0.50.xip.io:3000' will resolve to '192.168.0.50:3000'

Solution 3 - Google Oauth

I ran into this issue too and so I entered a URL with a .com extension and also entered it into my /etc/hosts file. Works like a charm.

It totally sucks that my entire app now has to be developed on an apparently 'live' domain though.

Solution 4 - Google Oauth

I used my public hostname. It helps if you have a static IP address. I used http://www.displaymyhostname.com/ to get my hostname. I plugged it straight into the Authorized JavaScript origins field when I created a new Web Application Client ID.

P.S. My hostname looked something like this: 111.111.111.111.static.exetel.com.au

Solution 5 - Google Oauth

You can use a dynamic DNS. I used ddns.net which offers a free solution. Basically, you enter your FQDN as this: yourcompany.ddns.net as your domain. When looked up for an IP address, the .net domain points to ddns; when ddns.net is looked up, it looks up in its database for your company, returns the IP. So mine looks like this: https://wigwam.ddns.net and everything works fine. You don't need to buy a domain, you can substitute your known IP, and Google is happy with that.

Your IP must be static, of course.

Solution 6 - Google Oauth

Yes, as of now you still need to have a domain name to use Google OAuth in your application. If you have a static public IP and don't want to buy a domain name, you could use a free subdomain from FreeDNS to link to your public IP. Seemed to work well enough for me with a Django app.

Solution 7 - Google Oauth

Echoing what Breno said in response to his earlier comment:

Apologies for the lack of updates here. Essential app verification activities have continued to make support of IP address-based apps unlikely. These verification activities are necessary to provide protections against abuse of user accounts. In addition, the cost of setting up dedicated domains has been reduced significantly since this feature was requested. Please read other responses here about possible options.

You can read more about Google's app verification requirements [1] and Google's policies requiring secure handling of data [2].

[1] https://support.google.com/cloud/answer/9110914?hl=en

[2] https://developers.google.com/identity/protocols/oauth2/policies#secure-response-handling.

Solution 8 - Google Oauth

xip.io is not working anymore as an alternative you can use nip.io the same way for example:
10.0.0.1.nip.io:8000 will resolve to 10.0.0.1:8000

Solution 9 - Google Oauth

It seems like xip.io is down, but there are alternatives such as sslip.io and nip.io. However, I couldn't get either of these to work.

I ended up hosting the main file server on the main machine, and ran said server on a 192.168.1.xx IP address. I then ran servers on each of the test machines (including a second server on the main machine), all of which were on the localhost address. Any requests that the localhost servers received were then passed off to the 192.168.1.xx server, which allowed testing on all of the devices.

This should also work with public facing IP addresses.

Solution 10 - Google Oauth

Try using the full server name.

It is obtained from MyPC/Properties... something like http://mypcname.mydomain.name:8080

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionjggView Question on Stackoverflow
Solution 1 - Google OauthbrenoView Answer on Stackoverflow
Solution 2 - Google OauthBARView Answer on Stackoverflow
Solution 3 - Google OauthTim FletcherView Answer on Stackoverflow
Solution 4 - Google OauthTysonView Answer on Stackoverflow
Solution 5 - Google OauthAndrew JayView Answer on Stackoverflow
Solution 6 - Google OauthsilveroxView Answer on Stackoverflow
Solution 7 - Google Oauthuser2705223View Answer on Stackoverflow
Solution 8 - Google OauthMohcen CHView Answer on Stackoverflow
Solution 9 - Google OauthsimplexshotzView Answer on Stackoverflow
Solution 10 - Google OauthtzakoView Answer on Stackoverflow