login static method
Implementation
static Future<Credential> login(
{String? clientId, String? clientSecret}) async {
var issuer = await Issuer.discover(Issuer.google);
var client = Client(
issuer,
clientId ?? String.fromEnvironment('FIREBASE_CLIENT_ID'),
clientSecret:
clientSecret ?? String.fromEnvironment('FIREBASE_CLIENT_SECRET'),
);
// create an authenticator
var authenticator = Authenticator(client,
scopes: [
'email',
'https://www.googleapis.com/auth/cloud-platform',
'https://www.googleapis.com/auth/cloudplatformprojects.readonly',
'https://www.googleapis.com/auth/firebase',
'openid'
],
port: 4000);
// starts the authentication
var c = await authenticator.authorize(); // this will open a browser
var v = {
'client_id': client.clientId,
'client_secret': client.clientSecret,
'refresh_token': c.response!['refresh_token']
};
var f = File(firebaseAdminCredentialPath!);
f.parent.createSync(recursive: true);
f.writeAsStringSync(JsonEncoder.withIndent(' ').convert(v));
var credential = RefreshTokenCredential(v);
return credential;
}