Google Auth - photoURL not updating

4,142 views
Skip to first unread message

Jethro Bodine

unread,
Jul 24, 2016, 1:15:09 PM7/24/16
to Firebase Google Group
I seem to be having inconsistency with how often, or at all, Google updates its photoURL with Firebase login. The auth token I receive back sometimes updates immediately when changing my profile pic for the Google account, but for all new ones, it has yet to update (the user.photoURL returns null).

Is this normal behavior to have to wait more than a few minutes to have the changes propogate, or could this be a bug of some sort?
Thanks

Jethro Bodine

unread,
Jul 25, 2016, 4:16:39 PM7/25/16
to Firebase Google Group
Ok, i was able to pinpoint the conditions.

It appears as if any new account logging in with google that doesn't already have a profile picture assigned will never update. If i upload a picture to that account then relogin to firebase, the photoURL returns null. However, if i delete that account in the Auth console, then login again thereby creating a new user, the photoURL will show up, and subsequent changes to the profile pic will eventually update as well.

Is this a Firebase Login specific issue, or something general about Google OAuth? and is there a potential quick fix, or is this something that will take time to remedy?

Thanks

Alfonso Gomez Jordana Manas

unread,
Jul 25, 2016, 7:34:42 PM7/25/16
to Firebase Google Group
Hi Jethro,

Federated provider data (like the photo url from Google) is updated every time a sign-in occurs with such provider. To access it, though, you have to use FirebaseUser#getProviderData() (or equivalent in other platforms) and then look up the specific provider you care about.

Top level data on the user object (e.g. photo url, retrievable via FirebaseUser#getPhotoUrl()) is only set automatically by Firebase Auth on the original sign up event as a convenience, but after that, it is left to the control of the developer to update it manually (via methods like FirebaseUser#setPhotoUrl() ).

In order to support your use case, the recommendation would be to:
1) After sign-in (or whenever you want to update the picture url), check if there are discrepancies between the photo url that comes from FirebaseUser#getPhotoUrl() and FirebaseUser#getProviderData() ->[google provider] UserInfo#getPhotoUrl()
2) If both values aren't the same, call FirebaseUser#setPhotoUrl() with the value coming from Google.

Reply back if you have further questions.

Jethro Bodine

unread,
Jul 25, 2016, 7:45:20 PM7/25/16
to Firebase Google Group
Thank you for the response. I was under the impression it updated each time, so this makes sense. My case is for the Web platform, so I'm digging into those docs now, and will be sure to ask if I run into any hurdles there. Thanks again for the timely help!

Jethro Bodine

unread,
Jul 25, 2016, 10:06:55 PM7/25/16
to Firebase Google Group
Hey Alfonso. It appears I'm having no luck in figuring out how to get the new provider data from Google Sign-In in this case. I don't see any equivalent methods in the web version, or more likely I'm not understanding the proper way to achieve it. 

Auth is the only part thats ever given me any trouble in Firebase. Any guidance here is much appreciated.

Bassam

unread,
Jul 26, 2016, 2:18:11 AM7/26/16
to Firebase Google Group
Hey Jethro, compare:
firebase.auth().currentUser['photoURL'] and firebase.auth().currentUser['providerData'][0]['photoURL'] where 0 is the index of the google provider.
To update profile:
firebase.auth().currentUser.updateProfile({
  'displayName': 'Jack Smith',
}).then(function() {});
Reply all
Reply to author
Forward
0 new messages