postIdentityToolkitSignInWithCustomToken function
Signs in with a Firebase custom token via the Identity Toolkit REST API.
Implementation
Future<Map<String, dynamic>> postIdentityToolkitSignInWithCustomToken({
required String customToken,
required String apiKey,
int maxAttempts = 5,
}) async {
Object? lastError;
for (var attempt = 1; attempt <= maxAttempts; attempt++) {
try {
return await _postIdentityToolkitSignInOnce(
customToken: customToken,
apiKey: apiKey,
);
} catch (error) {
lastError = error;
final retryable = _isRetryableAuthError(error);
if (!retryable || attempt >= maxAttempts) {
rethrow;
}
await Future<void>.delayed(Duration(milliseconds: 250 * attempt));
}
}
throw lastError ?? StateError('Identity Toolkit sign-in failed.');
}