Getting Google contacts using LightOpenID?

I am currently using LightOpenID so that users can register on my site where I can automatically retrieve their username and email address:

$openid->required = array('namePerson/first', 'namePerson/last', 'contact/email'); $openid->identity = 'https://www.google.com/accounts/o8/id'; 

Here I use the parameters namePerson/first , namePerson/last and contact/email .

I understand that to get a list of user contacts I need to use the feed:

 https://www.google.com/m8/feeds 

However, I can’t understand what parameters I need to use for this?

If I completely delete the parameter string, I just return an empty array.

Can anyone help me figure out what options I need to get contacts?

Here is the current code that I have:

 <?php require '/var/www/libraries/openid.php'; try { $openid = new LightOpenID; if(!$openid->mode) { //$openid->required = array('gd/fullName'); $openid->identity = 'https://www.google.com/m8/feeds/contacts/oshirowanen.y%40gmail.com/full'; header('Location: ' . $openid->authUrl()); exit; } elseif($openid->mode == 'cancel') { echo "cancelled"; exit; } else { if ( $openid->validate() ) { $returned = $openid->getAttributes(); print_r($returned); exit; } else { echo "something is wrong"; exit; } } } catch(ErrorException $e) { echo $e->getMessage(); } ?> 
+7
source share
3 answers

You cannot do this with LightOpenID, because it only implements the OpenID protocol.

For this, you will need the OAuth protocol (2.0). Per:

About authorization protocols

We recommend using OAuth 2.0 to authorize requests.

If your application has some unusual authorization requirements, for example, logging in at the same time as requesting data access (hybrid) or delegating domain authority (2LO), then you cannot currently use OAuth 2.0 tokens. In such cases, you should use OAuth 1.0 and the API key instead. You can find your key application API in the Google API console, in the "Easy Access to API" section of the Access API.

+5
source

In the docs :

Getting all contacts

To get all user contacts, send an authorized GET request to the following URL:

https://www.google.com/m8/feeds/contacts/ {userEmail} / full

Using the appropriate value instead of userEmail.

Note. The default value for a special Email user can be used to refer to an authenticated user.

0
source

This should be possible according to the docs: https://developers.google.com/accounts/docs/OpenID

The OpenID + OAuth Hybrid protocol allows web developers to combine an OpenID request with an OAuth authentication request. This extension is useful for web developers who use OpenID and OAuth, especially in that it simplifies the process for users by requesting their approval once rather than twice.

0
source

All Articles