2

I'm working on a web app that modifies a user's Google Calendar events and can display their user profile name and image(avatar). After doing some research I found out that:

https://developers.google.com/calendar/ Google Calendar API which is very intuitive but has no mention of getting a user's profile info.

https://developers.google.com/identity/sign-in/web/ Google sign-in API which is very intuitive but has a sign-in mechanism that seems completely different from the Calendar API.

Which one should I go for? Thank you.

Ivan
  • 51
  • 1
  • 9
  • 1
    Related question: https://stackoverflow.com/questions/14243200/find-google-avatar-for-given-email-address-without-oauth – Maximillian Laumeister Sep 23 '18 at 19:42
  • 1
    @MaximillianLaumeister this looks good, but in order to use that I'll need Calendar API to be able to give me user's email address, which it can't. – Ivan Sep 23 '18 at 20:26

1 Answers1

1

If you look at the calendar's quickstart https://developers.google.com/calendar/quickstart/js there is

gapi.auth2.getAuthInstance()

it returns gapi.auth2.GoogleAuth which has currentUser.get(). So you could

var profile = gapi.auth2.getAuthInstance().currentUser.get()

to get the profile.

then profile.getBasicProfile() to obtain name, avatar and other.

Hope it's helpful.

Evgeny Timoshenko
  • 3,119
  • 5
  • 33
  • 53