A problem I have is when a user login with Apple at first, and then he updates the Email, so it causes the refresh token to expire. According to the document here, refresh token will expire when email address has been updated.
I tried to use reauthenticate function as below, but the credential must be created first as parameters. In order to get the credential, the user must re-login Apple again in order to get a new nonce, is there any way to avoid the prompt of the apple login window again, and also to get the credential smoothly?
let credential = OAuthProvider.credential(withProviderID: "apple.com",
idToken: idToken,
rawNonce: nonce)
let user = Auth.auth().currentUser
user?.reauthenticate(with: credential) { error in
if let error = error {
// An error happened.
} else {
// User re-authenticated.
}
}
I have seen an answer from here that I can get a new credential as below, but the key here is nil.
(error! As NSError) .userInfo [AuthErrorUserInfoUpdatedCredentialKey])