adc library
Application Default Credentials for servers and command line tools. Needs dart:io: import this library only in
code that does not run on the web.
It also exports OAuthTokenProvider and OAuthAccessToken.
import 'package:firebase_app_dart/firebase_app_dart.dart';
import 'package:firebase_auth_providers_dart/adc.dart';
void main() {
final FirebaseApp app = FirebaseApp.withOptions(
const FirebaseOptions(
apiKey: '',
appId: '1:1234567890:dart:server',
projectId: 'my-project',
),
);
app.authProvider = applicationDefaultCredentials();
}
Classes
- OAuthAccessToken
-
An OAuth 2.0 access token and when it expires: what the
fetchfunction of an OAuthTokenProvider returns. - OAuthTokenProvider
- A token provider for servers and command line tools: it hands out Google OAuth 2.0 access tokens (of a service account, or of Application Default Credentials) and gets a new one before the current one expires.
Functions
-
applicationDefaultCredentials(
{List< String> scopes = OAuthTokenProvider.datastoreScopes, Client? httpClient, Duration refreshBefore = const Duration(minutes: 5)}) → OAuthTokenProvider -
A token provider on top of Application Default Credentials: the key file named by the
GOOGLE_APPLICATION_CREDENTIALSenvironment variable, else the credentials ofgcloud auth application-default login, else the metadata server of the machine (Compute Engine, Cloud Run, GKE, ...). The lookup is the one ofpackage:googleapis_auth.