refreshToken method
Future<void>
refreshToken(
- Session session, {
- required AppleAccount appleAccount,
- required void onExpiredUserAuthentication(
- UuidValue authUserId
Refreshes the Apple appleAccount's refresh token to ensure it is still
valid.
If the token has been revoked, the onExpiredUserAuthentication callback
is invoked with the associated auth user's ID.
Implementation
Future<void> refreshToken(
final Session session, {
required final AppleAccount appleAccount,
required final void Function(UuidValue authUserId)
onExpiredUserAuthentication,
}) async {
await AppleAccount.db.updateRow(
session,
appleAccount.copyWith(lastRefreshedAt: clock.now()),
);
try {
await _signInWithApple.validateRefreshToken(
appleAccount.refreshToken,
useBundleIdentifier:
appleAccount.refreshTokenRequestedWithBundleIdentifier,
);
} on RevokedTokenException catch (_) {
onExpiredUserAuthentication(appleAccount.authUserId);
}
}