Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google OAuth2 not working on local development server - PHP Codeigniter spark

I am trying to use the Codeigniter spark ( http://getsparks.org/packages/oauth2/versions/HEAD/show) to allow users to login to my php site with fb and google.

My local dev site (on wampserver) is called mysite.dev, for which I have a etc/hosts file like :

127.0.0.1       mysite.dev

Facebook login works absolutely fine. But when I try logging with google, google complains : Invalid parameter value for redirect_uri: Non-public domains not allowed: http://mysite.dev/index.php/oauth2/session/google where oauth2 is my controller and session is the function where I specify fb/google, etc

any clues/hints?

like image 957
SIndhu Avatar asked Aug 28 '13 22:08

SIndhu


3 Answers

I got around this by adding a hosts file record for the domain with the dev part at the front rather than the end (which I usually do too):

/etc/hosts

127.0.0.1 localhost.mydomain.com

/etc/apache vhost

ServerName mydomain.com.localhost
ServerAlias localhost.mydomain.com

Then tell google to use:

http://localhost.mydomain.com/index.php/oauth2/session/google
like image 81
scipilot Avatar answered Nov 19 '22 21:11

scipilot


When you create client ID for web applications in Google APIs Console you can add allowed Redirect URIs. It accepts localhost urls and others as well.

like image 45
Naveed Avatar answered Nov 19 '22 22:11

Naveed


Google API Console does not allow 'mysite.dev'.

like image 5
emptywalls Avatar answered Nov 19 '22 20:11

emptywalls