Access Google Profile Data

Hey guys,

I am pretty new to nylas and want to receive the userinfo.profile from google to get the avatar url for my application. Is there a preferred way to do it with nylas?

Hello @Jarmo

We don’t provide profile information directly, so you will need to access Google’s APIs directly. Here’s a general approach using Google’s People API to retrieve profile information:

  1. Enable the People API on your Google Cloud Platform project where you have set up your Nylas integration.
  2. Obtain the appropriate Google scopes during your OAuth flow. For accessing photos, you might need scopes like https://www.googleapis.com/auth/userinfo.profile or https://www.googleapis.com/auth/photoslibrary.readonly .
  3. Use the access token to make requests to Google’s People API.Here is an example of how you might use a cURL command to retrieve profile information from Google:

bash
curl -H “Authorization: Bearer YOUR_ACCESS_TOKEN”
“https://people.googleapis.com/v1/people/me?personFields=photos”

Replace YOUR_ACCESS_TOKEN with the access token you obtained through Nylas’ Hosted Auth.

1 Like