GoogleSignInAccount getPhotoUrl() return null
According to Google's documentation - GoogleSignInAccount
public Uri getPhotoUrl ()
Gets the photo url of the signed in user.
Returns
photo url for the Google account. Only non-null if requestProfile() is configured and user does have a Google+ profile picture.
Please check if your Google account has had Google+ profile picture or not.
P/S: sometimes, if Google+ profile picture has been created already but after the time you add Google account in your device, perhaps you need to delete that existing Google account from your device, then re-add.
Was facing the same problem that is getting photoURL and tokenID as null
As @BNK had already explained what can be the other cause(s)
therefore just adding my solution into it, for someone who is facing the same problem (hoping, this help them)
While using below code (written in kotlin)
val gso = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.build()
I am just able to fetch information like 'DisplayName','Email','FamilyName','ID' except photoUrl and tokenId
So I just added 'requestIdToken' to GSO Builder like this:
val gso = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.requestIdToken(resources.getString(R.string.googleAccountWebClientID)) // This line did the magic for me
.build()
As a result of this I am able fetch all the information along with 'idToken' and 'photoUrl'
Note: Kindly use 'WebClientId' for requestIdToken() which you can get from (https://console.developers.google.com/apis/credentials?project=)