We are working on an iOS app that is using Google to authenticate with firebase. According to https://www.firebase.com/docs/ios/guide/user-auth.html#section-login Firebase says that auth tokens expire every 24 hours. We are wondering if the following scenario is something we need to consider:
- User authenticates with Google and Firebase
- Our app gets a Firebase auth token that expires in 24 hours
- User closes our iOS app
- 1 minute before the Firebase auth token expires, the user reopens the app
- A minute later we make a request to Firebase. The auth token has expired.
It seems we have to reauthenticate with Firebase by observing authentication changes per https://www.firebase.com/docs/ios/guide/user-auth.html#section-monitoring-authentication. But will we have to re-issue the same request to Firebase from #5 above? Also it seems we could reauthenticate in the cancelBlock:
[ref observeEventType:FEventTypeValue withBlock:^(FDataSnapshot *snapshot) {
NSLog(@"%@", snapshot.value);
} withCancelBlock:^(NSError *error) {
NSLog(@"%@", error.description);
// reauthenticate and then re-issue request?
}];
This would not be ideal because we would have to write this code everywhere that we make a request.
What are the best practices to deal with this scenario? Does Firebase automatically refresh the auth token when it's close to expiry?