22
33Open source authentication client library for Java.
44
5- [ ![ unstable ] ( http://badges.github.io/stability-badges/dist/unstable .svg )] ( http://github.com/badges/stability-badges )
5+ [ ![ stable ] ( http://badges.github.io/stability-badges/dist/stable .svg )] ( http://github.com/badges/stability-badges )
66[ ![ Maven] ( https://img.shields.io/maven-central/v/com.google.auth/google-auth-library-credentials.svg )] ( https://img.shields.io/maven-central/v/com.google.auth/google-auth-library-credentials.svg )
77
88- [ API Documentation] ( https://googleapis.dev/java/google-auth-library/latest )
99
1010This project consists of 3 artifacts:
1111
12- - [ * google-auth-library-credentials* ] ( #google-auth-library-credentials ) : contains base classes and
12+ - [ * google-auth-library-credentials* ] ( #google-auth-library-credentials ) : contains base classes and
1313interfaces for Google credentials
14- - [ * google-auth-library-appengine* ] ( #google-auth-library-appengine ) : contains App Engine
14+ - [ * google-auth-library-appengine* ] ( #google-auth-library-appengine ) : contains App Engine
1515credentials. This artifact depends on the App Engine SDK.
16- - [ * google-auth-library-oauth2-http* ] ( #google-auth-library-oauth2-http ) : contains a wide variety of
16+ - [ * google-auth-library-oauth2-http* ] ( #google-auth-library-oauth2-http ) : contains a wide variety of
1717credentials as well as utility methods to create them and to get Application Default Credentials
1818
19- > Note: This client is a work-in-progress, and may occasionally
20- > make backwards-incompatible changes.
19+ ** Table of contents:**
20+
21+
22+ * [ Quickstart] ( #quickstart )
23+
24+ * [ google-auth-library-oauth2-http] ( #google-auth-library-oauth2-http )
25+ * [ Application Default Credentials] ( #application-default-credentials )
26+ * [ ImpersonatedCredentials] ( #impersonatedcredentials )
27+ * [ Workload Identity Federation] ( #workload-identity-federation )
28+ * [ Downscoping with Credential Access Boundaries] ( #downscoping-with-credential-access-boundaries )
29+ * [ Configuring a Proxy] ( #configuring-a-proxy )
30+ * [ Using Credentials with google-http-client] ( #using-credentials-with-google-http-client )
31+ * [ Verifying JWT Tokens] ( #verifying-a-signature )
32+ * [ google-auth-library-credentials] ( #google-auth-library-credentials )
33+ * [ google-auth-library-appengine] ( #google-auth-library-appengine )
34+ * [ CI Status] ( #ci-status )
35+ * [ Contributing] ( #contributing )
36+ * [ License] ( #license )
37+
2138
2239## Quickstart
2340
@@ -53,64 +70,27 @@ libraryDependencies += "com.google.auth" % "google-auth-library-oauth2-http" % "
5370```
5471[ // ] : # ( {x-version-update-end} )
5572
56- ## google-auth-library-credentials
57-
58- This artifact contains base classes and interfaces for Google credentials:
59- - ` Credentials ` : base class for an authorized identity. Implementations of this class can be used to
60- authorize your application
61- - ` RequestMetadataCallback ` : interface for the callback that receives the result of the asynchronous
62- ` Credentials.getRequestMetadata(URI, Executor, RequestMetadataCallback) `
63- - ` ServiceAccountSigner ` : interface for a service account signer. Implementations of this class are
64- capable of signing byte arrays using the credentials associated to a Google Service Account
65-
66- ## google-auth-library-appengine
67-
68- This artifact depends on the App Engine SDK (` appengine-api-1.0-sdk ` ) and should be used only by
69- applications running on App Engine environments that use urlfetch. The ` AppEngineCredentials ` class
70- allows you to authorize your App Engine application given an instance of
71- [ AppIdentityService] [ appengine-app-identity-service ] .
72-
73- Usage:
74-
75- ``` java
76- import com.google.appengine.api.appidentity.AppIdentityService ;
77- import com.google.appengine.api.appidentity.AppIdentityServiceFactory ;
78- import com.google.auth.Credentials ;
79- import com.google.auth.appengine.AppEngineCredentials ;
80-
81- AppIdentityService appIdentityService = AppIdentityServiceFactory . getAppIdentityService();
73+ ## google-auth-library-oauth2-http
8274
83- Credentials credentials =
84- AppEngineCredentials . newBuilder()
85- .setScopes(... )
86- .setAppIdentityService(appIdentityService)
87- .build();
88- ```
75+ ### Application Default Credentials
8976
90- ** Important: ` com.google.auth.appengine.AppEngineCredentials ` is a separate class from
91- ` com.google.auth.oauth2.AppEngineCredentials ` .**
77+ This library provides an implementation of [ Application Default Credentials] ( https://google.aip.dev/auth/4110 )
78+ for Java. The [ Application Default Credentials] ( https://google.aip.dev/auth/4110 )
79+ provide a simple way to get authorization credentials for use in calling Google APIs.
9280
93- ## google-auth-library-oauth2-http
81+ They are best suited for cases when the call needs to have the same identity and
82+ authorization level for the application independent of the user. This is the recommended
83+ approach to authorize calls to Cloud APIs, particularly when you're building an application
84+ that uses Google Cloud Platform.
9485
95- ### Application Default Credentials
86+ Application Default Credentials also support workload identity federation to access
87+ Google Cloud resources from non-Google Cloud platforms including Amazon Web Services (AWS),
88+ Microsoft Azure or any identity provider that supports OpenID Connect (OIDC). Workload
89+ identity federation is recommended for non-Google Cloud environments as it avoids the
90+ need to download, manage and store service account private keys locally, see:
91+ [ Workload Identity Federation] ( #workload-identity-federation ) .
9692
97- This artifact contains a wide variety of credentials as well as utility methods to create them and
98- to get Application Default Credentials.
99- Credentials classes contained in this artifact are:
100- - ` CloudShellCredentials ` : credentials for Google Cloud Shell built-in service account
101- - ` ComputeEngineCredentials ` : credentials for Google Compute Engine built-in service account
102- - ` OAuth2Credentials ` : base class for OAuth2-based credentials
103- - ` ServiceAccountCredentials ` : credentials for a Service Account - use a JSON Web Token (JWT) to get
104- access tokens
105- - ` ServiceAccountJwtAccessCredentials ` : credentials for a Service Account - use JSON Web Token (JWT)
106- directly in the request metadata to provide authorization
107- - ` UserCredentials ` : credentials for a user identity and consent
108- - ` ExternalAccountCredentials ` : base class for credentials using workload identity federation to
109- access Google Cloud resources from non-Google Cloud platforms
110- - ` IdentityPoolCredentials ` : credentials using workload identity federation to access Google Cloud
111- resources from Microsoft Azure or any identity provider that supports OpenID Connect (OIDC)
112- - ` AwsCredentials ` : credentials using workload identity federation to access Google Cloud resources
113- from Amazon Web Services (AWS)
93+ #### Getting Application Default Credentials
11494
11595To get Application Default Credentials use ` GoogleCredentials.getApplicationDefault() ` or
11696` GoogleCredentials.getApplicationDefault(HttpTransportFactory) ` . These methods return the
@@ -125,7 +105,7 @@ following are searched (in order) to find the Application Default Credentials:
125105 - Skip this check by setting the environment variable ` NO_GCE_CHECK=true `
126106 - Customize the GCE metadata server address by setting the environment variable ` GCE_METADATA_HOST=<hostname> `
127107
128- ### Explicit Credential Loading
108+ #### Explicit Credential Loading
129109
130110To get Credentials from a Service Account JSON key use ` GoogleCredentials.fromStream(InputStream) `
131111or ` GoogleCredentials.fromStream(InputStream, HttpTransportFactory) ` . Note that the credentials must
@@ -652,11 +632,48 @@ try {
652632
653633For more options, see the [ ` TokenVerifier.Builder ` ] [ token-verifier-builder ] documentation.
654634
635+
636+ ## google-auth-library-credentials
637+
638+ This artifact contains base classes and interfaces for Google credentials:
639+ - ` Credentials ` : base class for an authorized identity. Implementations of this class can be used to
640+ authorize your application
641+ - ` RequestMetadataCallback ` : interface for the callback that receives the result of the asynchronous
642+ ` Credentials.getRequestMetadata(URI, Executor, RequestMetadataCallback) `
643+ - ` ServiceAccountSigner ` : interface for a service account signer. Implementations of this class are
644+ capable of signing byte arrays using the credentials associated to a Google Service Account
645+
646+ ## google-auth-library-appengine
647+
648+ This artifact depends on the App Engine SDK (` appengine-api-1.0-sdk ` ) and should be used only by
649+ applications running on App Engine environments that use urlfetch. The ` AppEngineCredentials ` class
650+ allows you to authorize your App Engine application given an instance of
651+ [ AppIdentityService] [ appengine-app-identity-service ] .
652+
653+ Usage:
654+
655+ ``` java
656+ import com.google.appengine.api.appidentity.AppIdentityService ;
657+ import com.google.appengine.api.appidentity.AppIdentityServiceFactory ;
658+ import com.google.auth.Credentials ;
659+ import com.google.auth.appengine.AppEngineCredentials ;
660+
661+ AppIdentityService appIdentityService = AppIdentityServiceFactory . getAppIdentityService();
662+
663+ Credentials credentials =
664+ AppEngineCredentials . newBuilder()
665+ .setScopes(... )
666+ .setAppIdentityService(appIdentityService)
667+ .build();
668+ ```
669+
670+ ** Important: ` com.google.auth.appengine.AppEngineCredentials ` is a separate class from
671+ ` com.google.auth.oauth2.AppEngineCredentials ` .**
672+
655673## CI Status
656674
657675Java Version | Status
658676------------ | ------
659- Java 7 | [ ![ Kokoro CI] ( http://storage.googleapis.com/cloud-devrel-public/java/badges/google-auth-library-java/java7.svg )] ( http://storage.googleapis.com/cloud-devrel-public/java/badges/google-auth-library-java/java7.html )
660677Java 8 | [ ![ Kokoro CI] ( http://storage.googleapis.com/cloud-devrel-public/java/badges/google-auth-library-java/java8.svg )] ( http://storage.googleapis.com/cloud-devrel-public/java/badges/google-auth-library-java/java8.html )
661678Java 8 OSX | [ ![ Kokoro CI] ( http://storage.googleapis.com/cloud-devrel-public/java/badges/google-auth-library-java/java8-osx.svg )] ( http://storage.googleapis.com/cloud-devrel-public/java/badges/google-auth-library-java/java8-osx.html )
662679Java 8 Windows | [ ![ Kokoro CI] ( http://storage.googleapis.com/cloud-devrel-public/java/badges/google-auth-library-java/java8-win.svg )] ( http://storage.googleapis.com/cloud-devrel-public/java/badges/google-auth-library-java/java8-win.html )
0 commit comments