load static method
Implementation
static Future<OpenIdIdentity?> load() async {
try {
late String? accessToken;
late String? refreshToken;
late String expiresOn;
late String tokenType;
late String? idToken;
late String? state;
await Future.wait([
_storage
.read(key: _AUTHENTICATION_TOKEN_KEY)
.then((value) => accessToken = value),
_storage
.read(key: _EXPIRES_ON_KEY)
.then((value) => expiresOn = value ?? "0"),
_storage.read(key: _ID_TOKEN_KEY).then((value) => idToken = value),
_storage
.read(key: _TOKEN_TYPE_KEY)
.then((value) => tokenType = value ?? "bearer"),
_storage
.read(key: _REFRESH_TOKEN_KEY)
.then((value) => refreshToken = value),
_storage.read(key: _STATE_KEY).then((value) => state = value),
]);
if (accessToken == null || idToken == null) return null;
return OpenIdIdentity(
accessToken: accessToken!,
expiresAt: DateTime.fromMillisecondsSinceEpoch(
int.parse(expiresOn),
),
idToken: idToken!,
tokenType: tokenType,
refreshToken: refreshToken,
state: state,
);
} on Exception catch (e) {
print(e.toString());
try {
clear();
} on Exception {}
return null; //Invalid values, flush.
}
}