How to get only email_ids (not G + id) from event API

I use the Google API to receive events and contacts on the user's calendar.

When extracting contacts, I get the answer as follows: -

[ { 'phones': [], 'image_path': '', 'id': 'ID', 'emails': ['email1'], 'name': ABC }, { 'phones': [], 'image_path': '', 'id': 'ID', 'emails': ['email2'], 'name': DEF } ] 

When I receive events, I get the following response: -

 [ { 'attendees': [{ 'organizer': True, 'displayName': 'ABC', 'id': 'Google+ Id', 'responseStatus': 'accepted' }, { 'self': True, 'displayName': 'DEF', 'id': 'Google+ id', 'responseStatus': 'accepted' }], 'organizer': { 'displayName': 'ABC', 'id': 'Google+ id' }, 'creator': { 'displayName': 'ABC', 'id': 'Google+ id' }, }, { 'organizer': { 'self': True, 'displayName': 'DEF', 'email': 'email2' }, 'creator': { 'self': True, 'displayName': 'DEF', 'email': 'email2' }, } ] 

As you can see, when retrieving events (from visitors, organizers, creators) I get a Google+ identifier in some cases and email_ids in other cases. This does not support uniformity in my code.

Since I dialed contacts with the user, and I'm looking for contacts through their email_ids. If I do not receive email_id among the participants, organizers or creators, I will not be able to refer to the contact object.

How can I make sure that I only receive visitors by email, not the Google+ ID.

+5
source share
1 answer

Google Calendar API Docs

Optional query parameters

 alwaysIncludeEmail 

boolean Always include a value in the email field for the organizer, creator and participants, even if a real email does not exist (i.e., a generated non-working value will be provided). Using this option is discouraged and should only be used by customers who cannot cope with the lack of email address values ​​in the mentioned locations. Optional. The default value is False.

In any case, it is not recommended to use it, because sometimes there is no real email message.

Work around:

You can use the G + API to receive a user’s email by providing his / her email.

Email
This area requests access to your application:

Google user account email address. You access the email address by calling people.get , which returns an array of email (or by calling people.getOpenIdConnect , which returns the email property in an OIDC compatible format). The Google Apps domain name, if any, to which the user belongs. The domain name is returned as a property of the domain from

people.get (or hd property from getOpenIdConnect)

This email area is equivalent to and replaces the https://www.googleapis.com/auth/userinfo.email area.

+1
source

Source: https://habr.com/ru/post/1238177/


All Articles