@@ -25,7 +25,13 @@ information, refer to [documentation](https://cloud.google.com/docs/authenticati
2525
2626
2727* [ Quickstart] ( #quickstart )
28-
28+ * [ Importing the Auth Library] ( #importing-the-auth-library )
29+ * [ Preferred: Libraries-Bom] ( #java-sdk-libraries-bom )
30+ * [ Auth-Bom] ( #google-auth-library-bill-of-materials )
31+ * [ Maven] ( #maven )
32+ * [ Gradle] ( #gradle )
33+ * [ Scala] ( #scala )
34+ * [ Migrating from GoogleCredential to GoogleCredentials] ( #migrating-from-googlecredential-to-googlecredentials )
2935* [ google-auth-library-oauth2-http] ( #google-auth-library-oauth2-http )
3036 * [ Application Default Credentials] ( #application-default-credentials )
3137 * [ ImpersonatedCredentials] ( #impersonatedcredentials )
@@ -55,10 +61,14 @@ information, refer to [documentation](https://cloud.google.com/docs/authenticati
5561
5662## Quickstart
5763
58- ### Preferred method: using ` java-libraries-bom `
59- If your use case is to enable authentication for a GAPIC library such as ` google-cloud-datastore ` ,
60- you may want simply add ` libraries-bom ` , which automatically imports the auth bom, to your pom.xml
61- as follows:
64+ ### Importing the Auth Library
65+
66+ #### Java SDK Libraries-Bom
67+ If you are trying to authenticate to a client library in the Java SDK (i.e. ` google-cloud-datastore ` ),
68+ you can import add ` libraries-bom ` to manage the versions of your dependencies. The BOM will pull in the
69+ versions of Auth Library compatible with the client library.
70+
71+ For example, importing with Maven from a pom.xml:
6272
6373[ // ] : # ( {x-version-update-start:google-auth-library-bom:released} )
6474``` xml
@@ -75,15 +85,16 @@ as follows:
7585</dependencyManagement >
7686```
7787
78- Otherwise, if you don't plan using libraries-bom, see the next section on
79- _ Google Auth Library Bill of Materials_ .
80-
81- ### Using Maven
88+ If you don't plan using libraries-bom or the client libraries, see the next section on
89+ [ Google Auth Library Bill of Materials] ( #google-auth-library-bill-of-materials ) to just import the relevant
90+ Auth modules.
8291
8392#### Google Auth Library Bill of Materials
84- In order to ensure transitive dependencies and the modules themselves are aligned with each other,
85- we rely on the Google Auth Library Bill of Materials. Please add this to your dependency management
86- section as follows:
93+ Alternatively, you can use the Google Auth Library Bill of Materials to ensure that the Auth modules
94+ and relevant transitive dependencies are compatible.
95+
96+ ##### Maven
97+ Add the following your pom.xml file
8798
8899[ // ] : # ( {x-version-update-start:google-auth-library-bom:released} )
89100``` xml
@@ -101,11 +112,9 @@ section as follows:
101112```
102113[ // ] : # ( {x-version-update-end} )
103114
104- #### Choosing your implementation
105-
106- If you are using Maven, add this to your pom.xml file (notice that you can replace
107- ` google-auth-library-oauth2-http ` with any of ` google-auth-library-credentials ` and
108- ` google-auth-library-appengine ` , depending on your application needs):
115+ In the ` <dependency> ` section, you can specify any of the Auth modules that are needed.
116+ For example, replace ` google-auth-library-oauth2-http ` below with any of ` google-auth-library-credentials `
117+ and ` google-auth-library-appengine ` , depending on your application needs):
109118
110119``` xml
111120<dependency >
@@ -116,8 +125,8 @@ If you are using Maven, add this to your pom.xml file (notice that you can repla
116125</dependency >
117126```
118127
119- ### Using Gradle
120- If you are using Gradle, add this to your dependencies
128+ ##### Gradle
129+ Add the following to your build.gradle file and specify any modules needed.
121130
122131[ // ] : # ( {x-version-update-start:google-auth-library-bom:released} )
123132``` Groovy
@@ -131,10 +140,11 @@ dependencies {
131140```
132141[ // ] : # ( {x-version-update-end} )
133142
134- Unfortunately, SBT [ cannot] ( https://github.com/sbt/sbt/issues/4531 ) manage dependencies via Maven
135- Bills of Materials. Therefore, you will have to add the submodule directly. Make sure the module
136- versions are aligned in case you are using more than one authentication module in order to prevent
137- transitive dependency conflicts.
143+ ##### Scala
144+ Unfortunately, SBT [ cannot] ( https://github.com/sbt/sbt/issues/4531 ) manage dependencies via Maven Bills of Materials. You will have to
145+ add the submodule directly. Make sure the module versions are aligned in case you are using more than
146+ one authentication module in order to prevent transitive dependency conflicts.
147+
138148If you are using SBT, add this to your dependencies
139149
140150[ // ] : # ( {x-version-update-start:google-auth-library-oauth2-http:released} )
@@ -144,6 +154,19 @@ libraryDependencies += "com.google.auth" % "google-auth-library-oauth2-http" % "
144154```
145155[ // ] : # ( {x-version-update-end} )
146156
157+ ### Migrating from GoogleCredential to GoogleCredentials
158+ [ GoogleCredential] ( https://cloud.google.com/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.auth.oauth2.GoogleCredential )
159+ from google-api-java-client is deprecated and GoogleCredentials is the recommended replacement.
160+
161+ We recommend users to instantiate GoogleCredentials with [ Application Default Credentials (ADC)] ( #application-default-credentials ) :
162+ ` GoogleCredentials credentials = GoogleCredentials.getApplicationDefault(); `
163+
164+ For [ Google Api Client Library] ( https://cloud.google.com/apis/docs/client-libraries-explained#google-api-client-libraries ) users, please refer to this
165+ [ guide] ( https://developers.google.com/api-client-library/java/google-api-java-client/requests ) for a example to instantiate a library with GoogleCredentials.
166+
167+ For [ Cloud Client Libraries] ( https://cloud.google.com/apis/docs/client-libraries-explained#cloud-client-libraries ) , the library will follow ADC to create a
168+ default GoogleCredential. Users do not need to manually create any Credentials or pass it into the library.
169+
147170## google-auth-library-oauth2-http
148171
149172### Application Default Credentials
0 commit comments