2

I've just downloaded the latest Google API PHP and I'm trying it out with a "log in with Google" script. The API is throwing this exception that is apparently uncaught:

Fatal error: Uncaught exception 'Google_Auth_Exception' with message 'No scopes specified' in /home/rlcoachi/public_html/hidden/googlelogin/src/Google/Client.php:178 Stack trace: #0 /home/rlcoachi/public_html/hidden/googlelogin/src/Google/Client.php(237): Google_Client->prepareScopes() #1 /home/rlcoachi/public_html/hidden/googlelogin/api.php(76): Google_Client->createAuthUrl() #2 {main} thrown in /home/rlcoachi/public_html/hidden/googlelogin/src/Google/Client.php on line 178

Line 74-77 of my api.php script is:

else 
{
    //For Guest user, get google login url
    $authUrl = $gClient->createAuthUrl();
}

gClient being a Google_Client object that's been setup with id, secret, url, key

Full script is available here

2 Answers 2

1

try:

$client->setScopes(array(
     'https://www.googleapis.com/auth/plus.login',
     'profile',
     'email',
     'openid',
));
Sign up to request clarification or add additional context in comments.

1 Comment

Please edit your answer to add an explanation of how your code works and how it solves the OP's problem. Many SO posters are newbies and will not understand the code you have posted.
1

Go to file named googlelogin/src/Google/Client.php

search

protected $scopes = array();

then fill the array with scopes like

protected $scopes = array("userinfo.email", "userinfo.profile");

if you want to get user emailId as well as profile details...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.