apiRestore static method
Restores an account by using a refresh token to log the user in again.
If a user has logged in once normally, you can store the refreshToken
and the later use this method to recreate the account instance without the
user logging in again. Internally, this method calls refresh() to obtain
user credentails and the returns a newly created account from the result.
The account is created by using the api
for accessing the Firebase REST
endpoints. If autoRefresh
and locale
are used to initialize these
properties.
If the refreshing fails, an AuthError
will be thrown.
Implementation
static Future<FirebaseAccount> apiRestore(
RestApi api,
String refreshToken, {
bool autoRefresh = true,
String? locale,
}) async {
final response = await api.token(refresh_token: refreshToken);
return FirebaseAccount._(
api,
response.user_id,
response.id_token,
response.refresh_token,
_expiresInToAt(_durFromString(response.expires_in)),
locale,
)..autoRefresh = autoRefresh;
}