@@ -25,7 +25,13 @@ information, refer to [documentation](https://cloud.google.com/docs/authenticati
25
25
26
26
27
27
* [ 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 )
29
35
* [ google-auth-library-oauth2-http] ( #google-auth-library-oauth2-http )
30
36
* [ Application Default Credentials] ( #application-default-credentials )
31
37
* [ ImpersonatedCredentials] ( #impersonatedcredentials )
@@ -55,10 +61,14 @@ information, refer to [documentation](https://cloud.google.com/docs/authenticati
55
61
56
62
## Quickstart
57
63
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:
62
72
63
73
[ // ] : # ( {x-version-update-start:google-auth-library-bom:released} )
64
74
``` xml
@@ -75,15 +85,16 @@ as follows:
75
85
</dependencyManagement >
76
86
```
77
87
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.
82
91
83
92
#### 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
87
98
88
99
[ // ] : # ( {x-version-update-start:google-auth-library-bom:released} )
89
100
``` xml
@@ -101,11 +112,9 @@ section as follows:
101
112
```
102
113
[ // ] : # ( {x-version-update-end} )
103
114
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):
109
118
110
119
``` xml
111
120
<dependency >
@@ -116,8 +125,8 @@ If you are using Maven, add this to your pom.xml file (notice that you can repla
116
125
</dependency >
117
126
```
118
127
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.
121
130
122
131
[ // ] : # ( {x-version-update-start:google-auth-library-bom:released} )
123
132
``` Groovy
@@ -131,10 +140,11 @@ dependencies {
131
140
```
132
141
[ // ] : # ( {x-version-update-end} )
133
142
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
+
138
148
If you are using SBT, add this to your dependencies
139
149
140
150
[ // ] : # ( {x-version-update-start:google-auth-library-oauth2-http:released} )
@@ -144,6 +154,19 @@ libraryDependencies += "com.google.auth" % "google-auth-library-oauth2-http" % "
144
154
```
145
155
[ // ] : # ( {x-version-update-end} )
146
156
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
+
147
170
## google-auth-library-oauth2-http
148
171
149
172
### Application Default Credentials
0 commit comments