google oauth2 server localhost

Wednesday, November 4, 2015

I have a virtual localhost (http://server.ehc.localhost) and I want to use the Google oauth in PHP.



In console (https://console.developers.google.com)
APIs&auth->credentials->myproject->credentials:



http://server.easyhomecosts.localhost:8081
http://server.easyhomecosts.localhost



I have always get the same error.




Authorized redirect URIs
Must have a protocol. Cannot contain URL fragments or relative paths. Cannot be a public IP address.




this is my code in php file



$client = new Google_Client();
$client->setClientId(CLIENTID);
$client->setClientSecret(CLIENTSECRET);
$client->setRedirectUri('http://server.easyhomecosts.localhost:8081');
$client->addScope("email");
$client->addScope("profile");
$service = new Google_Service_Oauth2($client);
$authUrl = $client->createAuthUrl();
echo '
';
echo '

Login with Google -- Demo

';
echo '';
echo '
';


the url generated is https://accounts.google.com/o/oauth2/auth?response_type=code&redirect_uri=http%3A%2F%2Fserver.easyhomecosts.localhost%3A8081&client_id=CLIENTID&scope=email+profile&access_type=online&approval_prompt=auto



I click on the link and I have always:




error: invalid_request Invalid parameter value for redirect_uri: Non-public domains not allowed: http://server.easyhomecosts.localhost:8081




Is it possible to use my localhost server?

0 comments:

Post a Comment