init method
Initializes authenticator and sets the project id.
Must be called before validate
is called.
Example
final validator = FirebaseAuthValidator();
await validator.init();
// ready to call validator.validate(token)
The project id will be automatically discovered if running on a Google Cloud service like Cloud Run or GCE, but you can manually specify the project id like so:
final validator = FirebaseAuthValidator();
await validator.init(projectId: 'PROJECT-ID');
// ready to call validator.validate(token)
Implementation
Future<void> init({String? projectId}) async {
if (_seededClient != null) {
client = _seededClient;
} else {
final calculatedProjectId = projectId ??
await currentProjectId(
platformWrapper: _platformWrapper,
httpClient: _httpClient,
);
final issuer =
await Issuer.discover(Issuer.firebase(calculatedProjectId));
client = Client(issuer, projectId);
}
}