Send feedback
Getting Profile Information
Stay organized with collections
Save and categorize content based on your preferences.
Warning:
Google Sign-In for Android is outdated and no longer supported. To ensure the
continued security and usability of your app,
migrate
to Credential Manager today. Credential Manager supports passkey,
password, and federated identity authentication (such as Sign-in with Google),
stronger security, and a more consistent user experience.
For Wear developers: Credential Manager will be supported in Wear OS 5.1 and
later on selected watches. Developers actively supporting Wear OS 3, 4 and 5.0
devices with Sign in with Google should continue using Google Sign-in for Android
for your Wear applications. Sign in with Google support will be available
on Credential Manager APIs for these versions of WearOS at a later date.
After you have signed in a user with Google, if you configured Google Sign-In ,
with the DEFAULT_SIGN_IN
parameter or the requestProfile
method, you can
access the user's basic profile information. If you configured Google Sign-In
with the requestEmail
method, you can also get their email address.
Before you begin
Use the GoogleSignIn.getLastSignedInAccount
method to request profile
information for the currently signed in user.
GoogleSignInAccount acct = GoogleSignIn.getLastSignedInAccount(getActivity());
if (acct != null) {
String personName = acct.getDisplayName();
String personGivenName = acct.getGivenName();
String personFamilyName = acct.getFamilyName();
String personEmail = acct.getEmail();
String personId = acct.getId();
Uri personPhoto = acct.getPhotoUrl();
}
Note: A Google account's email address can change, so don't use it to identify a
user. Instead, use the account's ID, which you can get on the client with
GoogleSignInAccount.getId
, and on the backend from the sub
claim of the ID
token.
For additional profile data that might be available, see
GoogleSignInAccount
.
Note that any of the profile fields can be null
, depending on which scopes
you requested and what information the user's profile includes.
Send feedback
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-09-30 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples / code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
Need to tell us more?
{"lastModified": "Last updated 2024-09-30 UTC."}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-09-30 UTC."]]