Dani
Dani

Reputation: 4177

Get token from Firebase.initializeApp()

When I log in using Facebook I get a photoURL with better quality like this:

...
FacebookAccessToken myToken = facebookUser.accessToken;
if (myToken == null) {
   return false;
}
AuthCredential credential = FacebookAuthProvider.credential(myToken.token);
...
User user = (await FirebaseAuth.instance.signInWithCredential(credential)).user;
this.facebookPhotoURL = user.photoURL + "/picture?height=600&access_token=" + myToken.token;

This is working fine and I can pass the height that I need but when I refresh the status of the app or I reboot it I'm not performing this login, I just get the user by doing this:

await Firebase.initializeApp();

How could I get the token from this or from a different method?

Upvotes: 0

Views: 449

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 598847

Firebase persists the credentials for Firebase Authentication, so that it can restore it when the app is restarted. It does however not persist the Facebook credentials (as it has no need for them after the initial sign-in).

So while you can get the Firebase token from the Firebase SDK, if you want to also get the Facebook access token you will either have to persist that yourself, or make another call to the Facebook SDK.

Upvotes: 1

Related Questions