You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: .readme-partials.yaml
+17-22
Original file line number
Diff line number
Diff line change
@@ -13,20 +13,12 @@ body: |-
13
13
- [Downscoped Client](#downscoped-client) - Use Downscoped Client with Credential Access Boundary to generate a short-lived credential with downscoped, restricted IAM permissions that can use for Cloud Storage.
14
14
15
15
## Application Default Credentials
16
-
This library provides an implementation of [Application Default Credentials](https://cloud.google.com/docs/authentication/getting-started) for Node.js. The [Application Default Credentials](https://cloud.google.com/docs/authentication/getting-started) provide a simple way to get authorization credentials for use in calling Google APIs.
17
16
18
-
They are best suited for cases when the call needs to have the same identity and authorization level for the application independent of the user. This is the recommended approach to authorize calls to Cloud APIs, particularly when you're building an application that uses Google Cloud Platform.
17
+
This library provides an implementation of [Application Default Credentials (ADC)](https://cloud.google.com/docs/authentication/application-default-credentials) for Node.js. ADC provides a simple way to get credentials for use in calling Google APIs. How you [set up ADC](https://cloud.google.com/docs/authentication/provide-credentials-adc) depends on the environment where your code is running.
19
18
20
-
Application Default Credentials also support workload identity federation to access Google Cloud resources from non-Google Cloud platforms including Amazon Web Services (AWS), Microsoft Azure or any identity provider that supports OpenID Connect (OIDC). Workload identity federation is recommended for non-Google Cloud environments as it avoids the need to download, manage and store service account private keys locally, see: [Workload Identity Federation](#workload-identity-federation).
19
+
ADC is best suited for cases when the call needs to have the same identity and authorization level for the application independent of the user. This is the recommended approach to authorize calls to Cloud APIs, particularly when you're building an application that uses Google Cloud Platform.
21
20
22
-
#### Download your Service Account Credentials JSON file
23
-
24
-
To use Application Default Credentials, You first need to download a set of JSON credentials for your project. Go to **APIs & Auth** > **Credentials** in the [Google Developers Console](https://console.cloud.google.com/) and select **Service account** from the **Add credentials** dropdown.
25
-
26
-
> This file is your *only copy* of these credentials. It should never be
27
-
> committed with your source code, and should be stored securely.
28
-
29
-
Once downloaded, store the path to this file in the `GOOGLE_APPLICATION_CREDENTIALS` environment variable.
21
+
Application Default Credentials also supports Workload Identity Federation to access Google Cloud resources from non-Google Cloud platforms including Amazon Web Services (AWS), Microsoft Azure or any identity provider that supports OpenID Connect (OIDC). Workload Identity Federation is recommended for non-Google Cloud environments as it avoids the need to download, manage and store service account private keys locally, see: [Workload Identity Federation](#workload-identity-federation).
30
22
31
23
#### Enable the API you want to use
32
24
@@ -64,7 +56,7 @@ body: |-
64
56
65
57
## OAuth2
66
58
67
-
This library comes with an [OAuth2](https://developers.google.com/identity/protocols/OAuth2) client that allows you to retrieve an access token and refreshes the token and retry the request seamlessly if you also provide an `expiry_date` and the token is expired. The basics of Google's OAuth2 implementation is explained on [Google Authorization and Authentication documentation](https://developers.google.com/accounts/docs/OAuth2Login).
59
+
This library comes with an [OAuth2](https://developers.google.com/identity/protocols/OAuth2) client that allows you to retrieve an access token and refreshes the token and retry the request seamlessly if you also provide an `expiry_date` and the token is expired. The basics of Google's OAuth2 implementation is explained on [Google authorization and Authentication documentation](https://developers.google.com/accounts/docs/OAuth2Login).
68
60
69
61
In the following examples, you may need a `CLIENT_ID`, `CLIENT_SECRET` and `REDIRECT_URL`. You can find these pieces of information by going to the [Developer Console](https://console.cloud.google.com/), clicking your project > APIs & auth > credentials.
70
62
@@ -111,11 +103,11 @@ body: |-
111
103
return new Promise((resolve, reject) => {
112
104
// create an oAuth client to authorize the API call. Secrets are kept in a `keys.json` file,
113
105
// which should be downloaded from the Google Developers Console.
114
-
const oAuth2Client = new OAuth2Client(
115
-
keys.web.client_id,
116
-
keys.web.client_secret,
117
-
keys.web.redirect_uris[0]
118
-
);
106
+
const oAuth2Client = new OAuth2Client({
107
+
clientId: keys.web.client_id,
108
+
clientSecret: keys.web.client_secret,
109
+
redirectUri: keys.web.redirect_uris[0]
110
+
});
119
111
120
112
// Generate the url that will be used for the consent dialog.
**Important**: If you accept a credential configuration (credential JSON/File/Stream) from an external source for authentication to Google Cloud, you must validate it before providing it to any Google API or library. Providing an unvalidated credential configuration to Google APIs can compromise the security of your systems and data. For more information, refer to [Validate credential configurations from external sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
304
+
311
305
#### Using a Proxy
312
306
You can set the `HTTPS_PROXY` or `https_proxy` environment variables to proxy HTTPS requests. When `HTTPS_PROXY` or `https_proxy` are set, they will be used to proxy SSL requests that do not have an explicit proxy configuration option present.
313
307
@@ -434,6 +428,7 @@ body: |-
434
428
audience: '//iam.googleapis.com/projects/$PROJECT_NUMBER/locations/global/workloadIdentityPools/$WORKLOAD_POOL_ID/providers/$PROVIDER_ID', // Set the GCP audience.
435
429
subject_token_type: 'urn:ietf:params:aws:token-type:aws4_request', // Set the subject token type.
436
430
aws_security_credentials_supplier: new AwsSupplier("AWS_REGION") // Set the custom supplier.
431
+
service_account_impersonation_url: 'https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/$EMAIL:generateAccessToken', // Set the service account impersonation url.
437
432
}
438
433
439
434
// Create a new Auth client and use it to create service client, i.e. storage.
@@ -996,19 +991,19 @@ body: |-
996
991
}
997
992
998
993
const clientOptions = {
999
-
audience: '//iam.googleapis.com/locations/global/workforcePools/$WORKLOAD_POOL_ID/providers/$PROVIDER_ID', // Set the GCP audience.
994
+
audience: '//iam.googleapis.com/locations/global/workforcePools/$WORKFORCE_POOL_ID/providers/$PROVIDER_ID', // Set the GCP audience.
1000
995
subject_token_type: 'urn:ietf:params:oauth:token-type:id_token', // Set the subject token type.
1001
996
subject_token_supplier: new CustomSupplier() // Set the custom supplier.
1002
997
}
1003
998
1004
999
const client = new CustomSupplier(clientOptions);
1005
1000
```
1006
1001
1007
-
Where the audience is: `//iam.googleapis.com/locations/global/workforcePools/$WORKLOAD_POOL_ID/providers/$PROVIDER_ID`
1002
+
Where the audience is: `//iam.googleapis.com/locations/global/workforcePools/$WORKFORCE_POOL_ID/providers/$PROVIDER_ID`
1008
1003
1009
1004
Where the following variables need to be substituted:
1010
1005
1011
-
* `WORKFORCE_POOL_ID`: The worforce pool ID.
1006
+
* `$WORKFORCE_POOL_ID`: The worforce pool ID.
1012
1007
* `$PROVIDER_ID`: The provider ID.
1013
1008
1014
1009
and the workforce pool user project is the project number associated with the [workforce pools user project](https://cloud.google.com/iam/docs/workforce-identity-federation#workforce-pools-user-project).
0 commit comments