google_oauth2 1.0.4 google_oauth2: ^1.0.4 copied to clipboard
A Dart library for generating OAuth 2.0 access tokens for Google APIs using JSON service account credentials.
example/google_oauth2_example.dart
import 'package:google_oauth2/google_oauth2.dart';
Future<void> main() async {
final Map<String, dynamic> json = {
/*'service-account.json'*/
};
final scopes = [
'https://www.googleapis.com/auth/cloud-platform',
'https://www.googleapis.com/auth/firebase.messaging',
];
final scopesToTokenGenerator = genTokenFromJson(json);
final tokenGenerator = scopesToTokenGenerator(scopes);
await tokenGenerator.generate().then((token) => print(token));
}