Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google API - How to redirect URL to my localhost

I am working on integrating google login in my Phonegap app using Google OAuth. What happens is that while creating a client ID for my app, I have to choose "Installed Application" and then the application type as "Others" since I am creating my app using Phonegap.

This gives me two redirect URIs such as "urn:ietf:wg:oauth:2.0:oob" and "http://localhost". I am not opting to go with "urn:ietf:wg:oauth:2.0:oob" as it requires the user to copy the code and put it back to the app. The other option that I have is redirecting to localhost.

Here the problem is that how do I redirect the URL to localhost when I am on iPad? I have tried to use different redirect URIs but Google doesn't let me use them. It sticks only with redirecting to localhost (or adding some port numbers) which I have no other go.

Does anyone have any workaround on this? Are there any methods to accomplish this task? I am stuck. Please help.

like image 421
GenieWanted Avatar asked Dec 27 '12 10:12

GenieWanted


People also ask

Can you use OAuth on localhost?

Setup steps To test a web OAuth client you can still use a localhost deployment, provided you have administrator (superuser) permissions to modify the local lookup table for hostnames.

What is redirect URI in API?

A redirect URI, or reply URL, is the location where the authorization server sends the user once the app has been successfully authorized and granted an authorization code or access token.


1 Answers

You can use Rewrite Rules too.

For example, I need this callback for Google : http://local.dev/users/login-google

So I have set this URL in Google Console : http://localhost/JUMP/local.dev/users/login-google

And in apache, a simple redirect :

RewriteEngine  on
RewriteRule    ^JUMP/(.+)$   http://$1 [R,L]
like image 103
Potsky Avatar answered Nov 15 '22 08:11

Potsky