getIdToken method
- [bool forceRefresh = false]
Gets the ID token quickly without refresh.
Returns the current token string. Gets the ID token quickly without refresh.
Returns the current token string. Gets the ID token, refreshing if necessary.
forceRefresh Whether to force refresh (default false).
Returns a Future with the token string.
Example:
String? token = await user.getIdToken(true);
Implementation
// String getIdTokenResultFast() {
// return _userHelper.accessToken.token;
// }
/// Gets the ID token quickly without refresh.
///
/// Returns the current token string.
// String getFUSABASETokenFast() {
// return _userHelper.fusabaseToken.token;
// }
/// Gets the ID token, refreshing if necessary.
///
/// [forceRefresh] Whether to force refresh (default false).
///
/// Returns a [Future] with the token string.
///
/// Example:
/// ```dart
/// String? token = await user.getIdToken(true);
/// ```
Future<String?> getIdToken([bool forceRefresh = false]) async {
IdTokenResult? laccessToken = await _auth.__getIdTokenResult(
_auth.app.options.appID + globals.accessTokenKey,
);
String? lrefreshToken = await _auth.__getToken(
_auth.app.options.appID + globals.refreshTokenKey,
);
if (forceRefresh || !_userHelper.vaidateAccessToken(laccessToken)) {
dynamic tok = await _userHelper.refreshAccessToken(
client: createClient(_auth.app),
refreshToken: lrefreshToken,
);
_refreshToken = tok["refresh_token"];
_accessToken = IdTokenResult(token: tok["access_token"]);
laccessToken = IdTokenResult(token: tok["access_token"]);
_auth.idTokenController.add(this);
_auth.userController.add(this);
_auth._syncLoginPersistence(
tok["access_token"],
tok["refresh_token"] ?? "",
);
await _auth.__setCredTokens({
"accessToken": _accessToken,
"refreshToken": tok["refresh_token"],
});
}
return laccessToken?.token;
}