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?
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
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.
Google API 控制台不允许使用“mysite.dev”。
Adding
127.0.0.1 localhost.mydomain.com
to my hosts
file and
http://localhost.mydomain.com/oauth2callback
to "Authorized redirect URIs" worked for me
If you only want to run the OAuth process once on your dev site, there is a quick workaround.
Login to your Google Cloud Console, visit APIs & Services ▸ Credentials ▸ OAuth 2.0 Client IDs ▸ Authorised Redirect URIs and a New URI with the following value:
http://localhost/index.php/oauth2/session/google
Then navigate to your dev site using localhost rather than mysite.dev as the domain. Go through the OAuth process on localhost. Google should now accept your return URI. Once successfully authorised, you can go back to using mysite.dev.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.