This is Google's officially supported node.js client library for using OAuth 2.0 authorization and authentication with Google APIs.
- Before you begin
- Samples
- Adc
- Authenticate API Key
- Authenticate Explicit
- Authenticate Implicit With Adc
- Compute
- Credentials
- Downscopedclient
- Headers
- Id Token From Impersonated Credentials
- Id Token From Metadata Server
- Id Token From Service Account
- ID Tokens for Identity-Aware Proxy (IAP)
- ID Tokens for Serverless
- Jwt
- Keepalive
- Keyfile
- Oauth2-code Verifier
- Oauth2
- Sign Blob
- Sign Blob Impersonated
- Verify Google Id Token
- Verifying ID Tokens from Identity-Aware Proxy (IAP)
- Verify Id Token
Before running the samples, make sure you've followed the steps outlined in Using the client library.
cd samples
npm install
cd ..
View the source code.
Usage:
node samples/adc.js
View the source code.
Usage:
node samples/authenticateAPIKey.js
View the source code.
Usage:
node samples/authenticateExplicit.js
View the source code.
Usage:
node samples/authenticateImplicitWithAdc.js
View the source code.
Usage:
node samples/compute.js
View the source code.
Usage:
node samples/credentials.js
View the source code.
Usage:
node samples/downscopedclient.js
View the source code.
Usage:
node samples/headers.js
View the source code.
Usage:
node samples/idTokenFromImpersonatedCredentials.js
View the source code.
Usage:
node samples/idTokenFromMetadataServer.js
View the source code.
Usage:
node samples/idTokenFromServiceAccount.js
Requests an IAP-protected resource with an ID Token.
View the source code.
Usage:
node idtokens-iap.js <url> <target-audience>
Requests a Cloud Run or Cloud Functions URL with an ID Token.
View the source code.
Usage:
node idtokens-serverless.js <url> [<target-audience>]
View the source code.
Usage:
node samples/jwt.js
View the source code.
Usage:
node samples/keepalive.js
View the source code.
Usage:
node samples/keyfile.js
View the source code.
Usage:
node samples/oauth2-codeVerifier.js
View the source code.
Usage:
node samples/oauth2.js
View the source code.
Usage:
node samples/signBlob.js
View the source code.
Usage:
node samples/signBlobImpersonated.js
View the source code.
Usage:
node samples/verifyGoogleIdToken.js
Verifying the signed token from the header of an IAP-protected resource.
View the source code.
Usage:
node verifyIdToken-iap.js <iap-jwt> [<project-number>] [<project-id>] [<backend-service-id>]
View the source code.
Usage:
node samples/verifyIdToken.js