2

I am trying to get Google+ connections that are visible. by referring to documentation https://developers.google.com/+/web/samples/php, it is clear that on adding 'plus.login' scope fetches G+ connections, age range and language.

But in my case this scope only asks permission for fetching age range and language. I am not able to fetch G+ connections.

I tried using google-api-php-client in my application. Also followed the quick start guide as mentioned in fresh application but access permission page does not include G+ connection in circle permission.

part of the code is below

    define('SCOPES', implode(' ',array(
    Google_Service_Plus::PLUS_ME, Google_Service_Plus::PLUS_LOGIN,Google_Service_Plus::USERINFO_EMAIL, Google_Service_People::CONTACTS 
            ))
        );

        Class GoogleClient {
            function getClient() {
                $client = new Google_Client();
                $client->setApplicationName(APPLICATION_NAME);
                $client->setScopes(SCOPES);
                $client->setAuthConfig(CLIENT_SECRET_PATH);
                $client->setAccessType('offline');

$this->authUrl = $client->createAuthUrl();

redirecting to the above created AuthUrl results in asking permissions displayed in picture

enter image description here

$plusConnections = new \Google_Service_Plus($client);
            $optParamsConnections = ['maxResults' => 99];
            $_people              = $plusConnections->people->listPeople('me', 'visible', $optParamsConnections);

$_people doesnt get any data. however for the same user when tried on Google API explorer, the connections are retrived

any suggestion why is this strange behaviour and how to resolve it thanks

Gunnrryy
  • 350
  • 1
  • 5
  • 17
  • Without seeing your code we cant help you figure out what's wrong. Its also hard to understand what the problem is exactly. I don't think its going to pop up and specifically request permissions for connected by adding that scope. – Linda Lawton - DaImTo Sep 20 '16 at 09:42
  • i want to fetch the g+ circle connections, which is possible using PLUS_LOGIN scope, but in my case that permission is not being asked. the other 2 things i.e. Age range and Lanugage access of PLUS_LOGIN are being asked. where is the issue? – Gunnrryy Sep 20 '16 at 10:00
  • There is none. Scope doesn't specifically say what its asking permissions for. as long as you are using plus login you should have access. – Linda Lawton - DaImTo Sep 20 '16 at 10:17
  • I also tried creating a new Google Account, a new google-project, new credentials, and tried again. but still no success – Gunnrryy Sep 20 '16 at 10:56

2 Answers2

2

The ability of the plus.login scope to retrieve connections, and the People.list endpoint itself, has been deprecated:

The Google+ People API list endpoint has been deprecated. In the past, the https://www.googleapis.com/auth/plus.login scope allowed access to a list of people in the user's circles in addition to their name and profile information. Starting in September 2016, new grants of the plus.login scope will allow access to only the user's name and profile info; calls to the API return empty circle data for those new sign-ins. In 2017 Q1, you will get empty circle data back for all users.

https://developers.google.com/+/web/people/#retrieve-a-collection-of-people

Eric Koleda
  • 12,420
  • 1
  • 33
  • 51
  • Thanks. i checked the link u have shared. and accordingly I am able to get the GoogleContacts of a user. My question is, is there any other way to fetch G+ connections of a circle? I tried finding it, but not able to find anything helpful in docs yet. – Gunnrryy Sep 21 '16 at 06:49
0

The authentication permissions screen is just a standard screen. It does not specifically say which methods you have access to. You should check the documentation in this case

People.list

Authorization
This request requires authorization with at least one of the following scopes (read more about authentication and authorization).
Scope https://www.googleapis.com/auth/plus.login

As long as you have sent the plus.login scope and the user accepts it you are able to use the people.list method. I actually think the one "Basic profile info" is the one you are looking for, it gives you access to a lot of the general Google Plus info for a user.

Side Note: you should try sending email scope or profile. If memory services they both just state "offline Access" which IMO is even more misleading to the users.

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
  • @DalmTo i saw the documentation, as u can see I have passed the plus.login scope but i am not able to fetch any of my connections. this was working and asking the permission on screen to access people in circle. – Gunnrryy Sep 20 '16 at 10:23
  • I need to see the code you are using for People.list make sure you are sending "visible" try the try me at the bottom of the documentation page so you can get an idea of how the API works. – Linda Lawton - DaImTo Sep 20 '16 at 10:25
  • have edited the OP, and mentioned the controller code where I am actually making the request. – Gunnrryy Sep 20 '16 at 10:30
  • @DalmTo tried with access_type commented, and added PLUS_ME, PLUS_LOGIN, USERINFO_EMAIL, USERINFO_PROFILE to scope. still not able to fetch the connections. I am trying to fetch the G+ connections, other info regarding User i am getting by OAuth2->get() method. – Gunnrryy Sep 20 '16 at 10:37
  • It has noting to do with the scope. If your problem was related to the scope you would get an access denied error (Forbidden) You have access only thing I can think of is the user you are using hasn't added anyone to circles. – Linda Lawton - DaImTo Sep 20 '16 at 10:45
  • nope. the user has connections and I am able to query it when i try it in the Google API explorer https://developers.google.com/apis-explorer/#s/plus/v1/plus.people.list – Gunnrryy Sep 20 '16 at 10:52