Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase facebook login photo url signature expired

I'm using Firebase (angularfire) and Facebook login in my APP to authenticate my users. However today I realized that the profile image URL had been expired, but the Firebase SDK isn't refreshing it.

Is there a way to solve this or should I request the image using the Facebook API?

like image 906
rena Avatar asked Dec 10 '22 13:12

rena


1 Answers

I solved this by using the photoURL that can be found within: user.providerData[0].photoURL Where user is the user data returned on

firebase.auth().onAuthStateChanged( user => {})

And [0] is the index of the Authentication Provider of interest. In my case I only have Facebook authentication, thus the index is 0.

Seems that this URL is somehow being updated... (maybe on user sign in?)

Edit: It seems that the URL is indeed being updated on user sign in. So be aware that if the user is "remembered" by the browser, with this method the image will eventually expire, if the user isn't forced to sign in again before expiration.

like image 73
John Bernardsson Avatar answered Dec 29 '22 09:12

John Bernardsson