Implementing OAuth2 access from localhost (and variants)

62,109 views
Skip to first unread message

daz

unread,
Mar 16, 2012, 11:04:37 AM3/16/12
to google-iden...@googlegroups.com
Hi,

Do you have a method for allowing local urls to be Redirect URIs?

Whilst by no means essential, when I'm developing my application locally, I would like to be able to test and use log-in functionality. This wasn't an issue with OpenId, hence the reason I'm now asking.

Regards,
Daz.

Jinhui Du

unread,
Mar 16, 2012, 11:57:57 AM3/16/12
to google-iden...@googlegroups.com
What error message do you get? Are you developing for the Hotmail IDP?

daz

unread,
Mar 16, 2012, 1:15:45 PM3/16/12
to google-iden...@googlegroups.com
Hi Jinhui,

This is for your just released OAuth2 access for the Google's IDP.


The redirect URI's are set as specified here: https://developers.google.com/console/help/#UsingOAuth2

Redirect URIs
A list of valid redirect URIs allowed in an authorization request. The first time an application applies for an authorization token, it sends a request that includes a redirect URI. The redirect URI indicates where Google should redirect the browser after the user allows (or denies) the authorization request. Web-based applications provide the URI of a handler page to call after the authorization request is complete; installed applications use a standard URI string. See the OAuth 2.0 documentation for details. If a web-based request does not include a URI listed here, the user will get an authorization error.

But these URI's can't be local, is there a solution?

Thanks,
Daz.

Jinhui Du

unread,
Mar 16, 2012, 1:25:27 PM3/16/12
to google-iden...@googlegroups.com
I have not tried out for "localhost". But from the https://code.google.com/apis/console -> API access -> Create another client ID -> Web Application, localhost is acceptable.

Mengcheng Duan

unread,
Mar 16, 2012, 1:45:42 PM3/16/12
to google-iden...@googlegroups.com
Google OAuth2 allows localhost as callback domain. Can you try again?

- Mengcheng


On Fri, Mar 16, 2012 at 10:15 AM, daz <dazbr...@gmail.com> wrote:

Darius Bradbury

unread,
Mar 16, 2012, 2:24:20 PM3/16/12
to google-iden...@googlegroups.com

OK, I updated my settings such that the redirect URI can be:

 

http://localhost/Callback

 

Now this works, however, in reality, I develop several applications and never run off purely localhost. I also often I use my PC name such that others on the LAN can access the test site.

 

Hence, when testing, I would really want my redirect URI to be a variant of:

 

http://customHostName/Callback

 

Thanks for the temporary solution however!

 

Regards,

Daz.

Naveen Agarwal

unread,
Mar 16, 2012, 4:07:09 PM3/16/12
to google-iden...@googlegroups.com
Hi Daz,

If this is for your machine, my suggestion is to use the host file trick during testing.
In your hosts file you can set (different way to do this depending on your OS)

<my IP address> mycustomdomain.com

Thanks

Naveen

daz

unread,
Mar 16, 2012, 4:54:18 PM3/16/12
to google-iden...@googlegroups.com
Hi Naveen,

Thanks, that makes sense, I have it working.

The only problem is that it just means it won't work for people on my LAN (for whom I can't edit their hosts file!). As the server isn't configured to respond to incoming requests from the web (by design), and I can't set the redirectURI to a url accessible only on my LAN, there is little left I can do (I think).

Cheers,
Daz.
Reply all
Reply to author
Forward
0 new messages