refreshAccessToken method
Obtain a new AuthToken once your access token has expired.
- An expired access token (short-lived) can be renewed using a refresh token (long-lived).
- Refreshing access tokens using an expired refresh token fails and invalidates all refresh tokens issued previously, for this ReachFive client only.
- The profile must have been granted the
offline_access
scope at the last authentication to obtain a refresh token. - For refresh token to be included in your AuthToken, your client must be configured on the ReachFive Console to enforce PKCE and to enable refresh tokens.
For more on refresh tokens, check out the Refresh Tokens page.
Implementation
Future<AuthToken> refreshAccessToken(AuthToken authToken) async {
try {
final authTokenInterface = await _platform.refreshAccessToken(
reachFiveKey: ReachFiveKeyConverter.toInterface(reachFiveKey),
authToken: AuthTokenConverter.toInterface(authToken),
);
return AuthTokenConverter.fromInterface(authTokenInterface);
} catch (error, stackTrace) {
try {
_platform.parseError(error, stackTrace);
} catch (interfaceError, interfaceStackTrace) {
adaptErrors(
error: interfaceError,
stackTrace: interfaceStackTrace,
);
}
}
}