Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase - Getting profile photo url from auth having Facebook provider after Graph 8.0 update

I am currently using Facebook login for firebase auth for my android app and retriving user's photourl using

firebaseAuth.getCurrentUser().getPhotoUrl()

This gives me the photo url from the user's facebook profile.

Recently I have received mail from Facebook stating - "Facebook will now require client or app access tokens to access a user’s profile picture when querying against user IDs. Beginning on October 24, 2020, queries for profile pictures made against user IDs without an access token will return a generic silhouette rather than a profile picture." More on it on this link https://developers.facebook.com/blog/post/2020/08/04/Introducing-graph-v8-marketing-api-v8

My question -

Does the request firebaseAuth.getCurrentUser().getPhotoUrl() use access tokens to access url from facebook and will it function the same after the release of Graph API 8.0 on 24th Oct? Or will I have to make a different query request to fetch the User's photo url for facebook provider?

like image 874
Sid Shinde Avatar asked Oct 06 '20 14:10

Sid Shinde


2 Answers

Unfortunately, you'll have to add the access token to the photo url by yourself as Firebase does not and will not support it (as they don't have access to it - you can read more about it here).

You'll have to do something along the lines of:

firebaseAuth.getCurrentUser().getPhotoUrl() + "?access_token=<facebook_access_token>"
like image 182
Marek Fořt Avatar answered Oct 12 '22 05:10

Marek Fořt


To be able to get the access token of facebook, after being logged-in with Firebase, you can use:

AccessToken.getCurrentAccessToken()

Complementing the answer of Marek Fort, with Kotlin you can get the picture doing something like that:

"${firebaseAuth.getCurrentUser().getPhotoUrl()}?access_token=${AccessToken.getCurrentAccessToken()}"
like image 22
enoler Avatar answered Oct 12 '22 05:10

enoler