0

I am working on login system where user is logged to website using google plus api . I am hitting "me" endpoint after token verification .But I am facing a problem in some cases where I don't get the displayName/Name object of the user . scopes used : plus.profile and plus.login Endpint hit : "me"

$service=new Google_Service_Plus($client);
    $userinfo=$service->people->get('me');

I want to fetch the username of the user .

Learner
  • 221
  • 2
  • 10
  • Is it consistent with specific users? Can you replicate it with the [APIs Explorer](https://developers.google.com/apis-explorer/#p/plus/v1/plus.people.get)? Are you sure you are not getting some error with the request that you are not catching? – abraham Feb 07 '15 at 19:05
  • @abraham: Yes , I am not even getting the result in API explorer . Problem is that i am getting displayName for some accounts and not for others . Is there any way to compel user for making a google plus account if he already do not have one . – Learner Feb 08 '15 at 18:33
  • I am getting blank names for those who are not google plus users . Is there any way to ask user to make a google plus account before signing into the application . – Learner Feb 08 '15 at 18:51
  • What `scopes` are you asking for during the sign-in flow? – abraham Feb 08 '15 at 19:31
  • I am using plus.email and plus.profile scopes . I think I need to use deprecated userinfo.email and userinfo.profile scopes in order to compel user to make a new google plus profile if his gmail account is not linked to google plus account . – Learner Feb 09 '15 at 06:29
  • If found the docs that specify when a G+ account is required and added an answer. You also shouldn't use deprecated scopes. – abraham Feb 09 '15 at 16:01

2 Answers2

1

Google+ Sign-In provides support for all users with a Google account, even if they have not yet created a Google+ profile. Your app can either prompt those users to create a Google+ profile (by using the https://www.googleapis.com/auth/plus.login scope) or not (by using the profile scope)

Switch to Google+ Sign-In

If you use the https://www.googleapis.com/auth/plus.login scope, users are guaranteed to have a Google+ profile.

abraham
  • 46,583
  • 10
  • 100
  • 152
0

If you want to bring information about the profile (Names) and Email.

I'd recommed you add the follow scopes separated by two spaces:

profile  email

profile bring the Names (givenName, familyName, etc.) and email bring the email.

Luigi Lopez
  • 1,037
  • 10
  • 23