google_oauth2 1.0.2 copy "google_oauth2: ^1.0.2" to clipboard
google_oauth2: ^1.0.2 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 'dart:io';

import 'package:google_oauth2/google_oauth2.dart';

Future<void> main() async {
  final file = File(
    // Provide path to your own service account file.
    'service-account.json',
  );

  final scopes = [
    'https://www.googleapis.com/auth/cloud-platform',
    'https://www.googleapis.com/auth/firebase.messaging',
  ];

  // If you are on the Web, [genTokenFromJson] is also available.
  final scopesToTokenGenerator = genTokenFromJsonFile(file);
  final tokenGenerator = scopesToTokenGenerator(scopes);

  await tokenGenerator.generate().then((token) => print(token));
}
1
likes
0
points
64
downloads

Publisher

verified publishersevasnex.dev

Weekly Downloads

A Dart library for generating OAuth 2.0 access tokens for Google APIs using JSON service account credentials.

Repository (GitHub)
View/report issues

Topics

#oauth #google-apis

License

unknown (license)

Dependencies

http, pointycastle

More

Packages that depend on google_oauth2