Class JWT (8.6.0)
Stay organized with collections
Save and categorize content based on your preferences.
Package
google-auth-library
Constructors
(constructor)(options)
constructor(options: JWTOptions);
JWT service account credentials.
Retrieve access token using gtoken.
Parameter
(constructor)(email, keyFile, key, scopes, subject, keyId)
constructor(email?: string, keyFile?: string, key?: string, scopes?: string | string[], subject?: string, keyId?: string);
Constructs a new instance of the JWT
class
Parameters
Name | Description |
email |
string
|
keyFile |
string
|
key |
string
|
scopes |
string | string[]
|
subject |
string
|
keyId |
string
|
Properties
additionalClaims
defaultScopes
defaultScopes?: string | string[];
defaultServicePath
defaultServicePath?: string;
email
gtoken
key
keyFile
keyId
scope
scopes
scopes?: string | string[];
subject
useJWTAccessWithScope
useJWTAccessWithScope?: boolean;
Methods
authorize()
authorize(): Promise<Credentials>;
Get the initial access token using gToken.
Returns
Type | Description |
Promise<Credentials> | Promise that resolves with credentials
|
authorize(callback)
authorize(callback: (err: Error | null, result?: Credentials) => void): void;
Parameter
Name | Description |
callback |
(err: Error | null, result?: Credentials) => void
|
Returns
createScoped(scopes)
createScoped(scopes?: string | string[]): JWT;
Creates a copy of the credential with the specified scopes.
Parameter
Name | Description |
scopes |
string | string[]
List of requested scopes or a single scope. The cloned instance.
|
Returns
fetchIdToken(targetAudience)
fetchIdToken(targetAudience: string): Promise<string>;
Parameter
Name | Description |
targetAudience |
string
the audience for the fetched ID token.
|
Returns
Type | Description |
Promise<string> | |
fromAPIKey(apiKey)
fromAPIKey(apiKey: string): void;
Creates a JWT credentials instance using an API Key for authentication.
Parameter
Name | Description |
apiKey |
string
The API Key in string form.
|
Returns
fromJSON(json)
fromJSON(json: JWTInput): void;
Create a JWT credentials instance using the given input options.
Parameter
Name | Description |
json |
JWTInput
The input object.
|
Returns
fromStream(inputStream)
fromStream(inputStream: stream.Readable): Promise<void>;
Create a JWT credentials instance using the given input stream.
Parameter
Name | Description |
inputStream |
stream.Readable
The input stream.
|
Returns
Type | Description |
Promise<void> | |
fromStream(inputStream, callback)
fromStream(inputStream: stream.Readable, callback: (err?: Error | null) => void): void;
Parameters
Name | Description |
inputStream |
stream.Readable
|
callback |
(err?: Error | null) => void
|
Returns
getCredentials()
getCredentials(): Promise<CredentialBody>;
Using the key or keyFile on the JWT client, obtain an object that contains the key and the client email.
Returns
protected getRequestMetadataAsync(url?: string | null): Promise<RequestMetadataResponse>;
Obtains the metadata to be sent with the request.
Parameter
Name | Description |
url |
string | null
the URI being authorized.
|
Returns
Type | Description |
Promise<RequestMetadataResponse> | |
refreshTokenNoCache(refreshToken)
protected refreshTokenNoCache(refreshToken?: string | null): Promise<GetTokenResponse>;
Refreshes the access token.
Parameter
Name | Description |
refreshToken |
string | null
ignored
|
Returns
Type | Description |
Promise<GetTokenResponse> | |
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-10-01 UTC.
[{
"type": "thumb-down",
"id": "hardToUnderstand",
"label":"Hard to understand"
},{
"type": "thumb-down",
"id": "incorrectInformationOrSampleCode",
"label":"Incorrect information or sample code"
},{
"type": "thumb-down",
"id": "missingTheInformationSamplesINeed",
"label":"Missing the information/samples I need"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
{"lastModified": "Last updated 2024-10-01 UTC."}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-10-01 UTC."]]