fetchAccountDetails method
Returns the account details for the given idToken.
Implementation
Future<FirebaseAccountDetails> fetchAccountDetails(
final Session session, {
required final String idToken,
}) async {
final String projectId = config.credentials.projectId;
Map<String, dynamic> data;
try {
data = await IdTokenVerifier.verifyOAuth2Token(
idToken,
config: FirebaseIdTokenConfig(projectId: projectId),
audience: projectId,
);
} catch (e, stackTrace) {
session.log(
'Firebase token verification failed: $e',
level: LogLevel.error,
exception: e,
stackTrace: stackTrace,
);
session.logAndThrow('Failed to verify ID token from Firebase');
}
FirebaseAccountDetails details;
try {
details = _parseAccountDetails(data);
} catch (e) {
session.logAndThrow('Invalid user info from Firebase: $e');
}
return details;
}