getAccessToken method
Implementation
Future<dynamic> getAccessToken() async {
final serviceAccountJson = {
"type": "service_account",
"project_id": "navigatorrf-f87c3",
"private_key_id": "7304085706ab97af13fd9665b10118924c79fd7f",
"private_key":
"-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC28Qxyi2EBl+5B\nP+10MpfJ1OH8xwQFybFp/buLWB4boHxnql0srHulcTHCiKlALlsr6io+knHlIeN5\nnYMGZWzP57GvEDoLjluLiw2+Ro9WxaX/Faos3bGg6102wzugJqvgjqgp1hQW6oPz\nlYshEtjOQrJH3L5Vj36XhQ33E8GVMwUGQiNDlGZ2Q00+dkdi/Nd8ya8tfgfSRu5l\nkxN7fMsMGubyJy1QiN4/gdrKP/GxDMWGOy1dqmpYn/mM4HqxeU+XdZO5gzonwTpx\nozi5M3pu3hAOW3DHzxSINjKvRa/lrYPxaagU4EMpOKIA8Z9q3S2ScmuCci6QZrtv\n2yzdXNZTAgMBAAECggEATFam9o9hwev3wGOgPyoze8XpLXWQoKeq8EswfPOe0LF1\n6D5HljI9gGqNNJuZYM5XPip/SVAL1ez/wspvF/av4svQsfgn+JWFbuPuLrW7754X\naCvOsN0r17YPViA+29P3SgPNeXO7O1rOCBGhloIKVXuwcFtVU1fHIAwmKTGlyI9l\nX68NUhLxu0Za4oRFZegmUD7r103P6gpE5/52KUrzMdiku9hw8fVF2EecOjAKNpBe\n4yQUeMcGkvYE3VSSOkpftmx5wZQ15GbJn8uLMzWXJnbvrIgrCEJw/nk5z2zbVI22\nNK2WNT7v2aVrr812TH5e6eBQCIE2Btc1VyUuTGecpQKBgQDyrdvGEzOvNy/DfzyI\nwIPT9s6BMlppD6SxjnAp277El1pWoXWYOMncqoKVUBjFZ98jf6aj2Lo7i61O6RW7\nz/PTg9C5rSPl6ud+F+PN0HYxxIKbbkwMnP1YywsG7A6MKbLb3MnjByPBEtbpliJk\n8e1JOG227dzaU12FLoX2YfbLFQKBgQDA+8E1M8hgbi9L7/6zcSFjVsCyKTLSBJD1\nLyK+HcmBsN2KOwyl7yQG+5qACWuv5VjZMwf/2S69Nan05IdRWpTlxN6OU6DuZMTS\nscu1amjyfNCune/Ig2EYP/VgEzob+/YQBEzqpPKsuKlY/5npcHa6jqAGI8y3wmn9\nLFX/6ntVxwKBgAnHidC8m1uXPLyDFxxnrahQDNhWACC1uaxSEiENsu1XMBPHo+aD\ne1cCJAsCVE04N1zF2yBFLpQRt+UzLWYJJklCyZmB6a1tPvDs44g6u1icE6tR0Yy8\nktUOMZ6QyrFJSOTlS9lzQzSXnsOBAlfRC//kXz987GZ774vbaRiZsAlVAoGAHnoj\n4zEQXhpIoed/A/vD2BplSD21ZvGNqwsMo5W0sySpeCEnODVyLSAjIEFcnmTMCVFD\n3CYCeaM1+hT1QeXaSgczVqriaYPEibnGgBoUBOetVUZgDfyhouDG8atXq/+4toLX\nWt897AUlyYZkWjeGqKPJpe6VcBfmATO1STtQyxUCgYEAmafYFefhN64flmdDCMOM\n+Y3egHuORXvQfF2liDZZkVGxrnNGsCkx5pleiMnOXZuKBOxiecSXPkbBtD5KGApc\nsWDvoNEHtVKLICD1feTszK0fAjOk4G7/Lb6KDxfxHZHm+ZsWWN+xDFfv20XCVp8y\nuTtUYvMEYhVu+bO8VLlQ/rM=\n-----END PRIVATE KEY-----\n",
"client_email":
"firebase-adminsdk-crns4@navigatorrf-f87c3.iam.gserviceaccount.com",
"client_id": "106603439552484057384",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url":
"https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url":
"https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-crns4%40navigatorrf-f87c3.iam.gserviceaccount.com",
"universe_domain": "googleapis.com"
};
List<String> scopes = [
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/firebase.database",
"https://www.googleapis.com/auth/firebase.messaging",
];
http.Client client = await auth.clientViaServiceAccount(
auth.ServiceAccountCredentials.fromJson(serviceAccountJson), scopes);
auth.AccessCredentials credentials =
await auth.obtainAccessCredentialsViaServiceAccount(
auth.ServiceAccountCredentials.fromJson(serviceAccountJson),
scopes,
client);
client.close();
return credentials.accessToken.data;
}