The flow for my application:
Login into Firebase through iOS. Retrieve the firebase token and store in the keychain -
FIRAuth.auth()?.currentUser?.getTokenWithCompletion({ (token, err) in
//store token in keychain
})
This token is sent in the header to my node server to authenticate requests -
firebase.auth().verifyIdToken(firebaseAccessToken).then(function(decodedToken) {
//allow access to api
}
The token then expires after an hour. My question is how should I handle this?
- Store the time the token was retrieved on the client and force a refresh if needed
- Refresh the token for every API call
- Use the token to authenticate, then create another token server side with a longer expiration time and store this as the auth token
Or is there another option here?