Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase iOS isn't getIDTokenForcingRefresh strictly better than getIDToken

By passing false to Auth.auth().currentUser?.getIDTokenForcingRefresh, the function does the same thing as getIDToken, except that in case when the current token is expired it will refresh the token. So isn't using getIDTokenForcingRefresh strictly better than using getIDToken? In what situation would anybody use getIDToken instead?

like image 539
Aaron Zorel Avatar asked Oct 27 '25 12:10

Aaron Zorel


1 Answers

Yes. It's better to use

func getIDTokenForcingRefresh(_ forceRefresh: Bool, completion: AuthTokenCallback? = nil)

But you should be careful about the forceRefresh param. If you set forceRefresh to true then it will refresh the token every time you call the method.

Rather you can also use

func getIDToken(completion: AuthTokenCallback? = nil)

Calling this method will refresh your token if needed, you don't have to take care about the forceRefresh param.

like image 87
Torongo Avatar answered Oct 30 '25 02:10

Torongo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!