Package com.google.auth.oauth2
Class JwtCredentials
java.lang.Object
com.google.auth.Credentials
com.google.auth.oauth2.JwtCredentials
- All Implemented Interfaces:
JwtProvider,Serializable
Credentials class for calling Google APIs using a JWT with custom claims.
Uses a JSON Web Token (JWT) directly in the request metadata to provide authorization.
JwtClaims claims = JwtClaims.newBuilder()
.setAudience("https://example.com/some-audience")
.setIssuer("some-issuer@example.com")
.setSubject("some-subject@example.com")
.build();
Credentials = JwtCredentials.newBuilder()
.setPrivateKey(privateKey)
.setPrivateKeyId("private-key-id")
.setJwtClaims(claims)
.build();
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from class com.google.auth.Credentials
GOOGLE_DEFAULT_UNIVERSE -
Method Summary
Modifier and TypeMethodDescriptionbooleangetRequestMetadata(URI uri) inthashCode()booleanbooleanjwtWithClaims(JwtClaims newClaims) Returns a copy of these credentials with modified claims.static JwtCredentials.Buildervoidrefresh()Refresh the token by discarding the cached token and metadata and rebuilding a new one.Methods inherited from class com.google.auth.Credentials
blockingGetToCallback, getMetricsCredentialType, getRequestMetadata, getRequestMetadata, getUniverseDomain
-
Method Details
-
newBuilder
-
refresh
Refresh the token by discarding the cached token and metadata and rebuilding a new one.- Specified by:
refreshin classCredentials- Throws:
IOException
-
jwtWithClaims
Returns a copy of these credentials with modified claims.- Specified by:
jwtWithClaimsin interfaceJwtProvider- Parameters:
newClaims- new claims. Any unspecified claim fields default to the current values.- Returns:
- new credentials
-
getAuthenticationType
- Specified by:
getAuthenticationTypein classCredentials
-
getRequestMetadata
- Specified by:
getRequestMetadatain classCredentials- Throws:
IOException
-
hasRequestMetadata
public boolean hasRequestMetadata()- Specified by:
hasRequestMetadatain classCredentials
-
hasRequestMetadataOnly
public boolean hasRequestMetadataOnly()- Specified by:
hasRequestMetadataOnlyin classCredentials
-
equals
-
hashCode
public int hashCode()
-