AI-generated Key Takeaways
-
This page provides code samples demonstrating how to read profile data using the People API after completing the initial setup.
-
You can retrieve the authenticated user's profile, including names and email addresses, using the provided code snippets.
-
The guide also includes code examples for fetching profile information for a specific Google Account ID, specifying the desired person fields.
After you've completed the steps in Get Ready to Use the People API, you are ready to read data for profiles.
The following code samples demonstrate how to send a few simple requests. For a full list of methods, see the reference documentation.
Get the person for the authenticated user
To get the user's profile, use the following code:
Protocol
GET /v1/people/me?personFields=names,emailAddresses HTTP/1.1 Host: people.googleapis.com
Java
Person profile = peopleService.people().get("people/me") .setPersonFields("names,emailAddresses") .execute();
Python
profile = people_service.people() .get('people/me', personFields='names,emailAddresses')
PHP
$profile = $people_service->people->get( 'people/me', array('personFields' => 'names,emailAddresses'));
.NET
PeopleResource.GetRequest peopleRequest = peopleService.People.Get("people/me"); peopleRequest.PersonFields = "names,emailAddresses"; Person profile = peopleRequest.Execute();
Get the person for a Google Account ID
To get the person information for a Google Account ID, use the following code:
Protocol
GET /v1/people/account_id?personFields=names,emailAddresses HTTP/1.1 Host: people.googleapis.com
Java
Person profile = peopleService.people().get("people/account_id") .setPersonFields("names,emailAddresses") .execute();
Python
profile = people_service.people() .get('people/account_id', personFields='names,emailAddresses')
PHP
$profile = $people_service->people->get( 'people/account_id', array('personFields' => 'names,emailAddresses'));
.NET
PeopleResource.GetRequest peopleRequest = peopleService.People.Get("people/account_id"); peopleRequest.PersonFields = "names,emailAddresses"; Person profile = peopleRequest.Execute();