public class JwtCredentials extends Credentials implements JwtProvider
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();
| Modifier and Type | Class and Description |
|---|---|
static class |
JwtCredentials.Builder |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj) |
String |
getAuthenticationType() |
Map<String,List<String>> |
getRequestMetadata(URI uri) |
int |
hashCode() |
boolean |
hasRequestMetadata() |
boolean |
hasRequestMetadataOnly() |
JwtCredentials |
jwtWithClaims(JwtClaims newClaims)
Returns a copy of these credentials with modified claims.
|
static JwtCredentials.Builder |
newBuilder() |
void |
refresh()
Refresh the token by discarding the cached token and metadata and rebuilding a new one.
|
blockingGetToCallback, getRequestMetadata, getRequestMetadatapublic static JwtCredentials.Builder newBuilder()
public void refresh()
throws IOException
refresh in class CredentialsIOExceptionpublic JwtCredentials jwtWithClaims(JwtClaims newClaims)
jwtWithClaims in interface JwtProvidernewClaims - new claims. Any unspecified claim fields default to the the current values.public String getAuthenticationType()
getAuthenticationType in class Credentialspublic Map<String,List<String>> getRequestMetadata(URI uri) throws IOException
getRequestMetadata in class CredentialsIOExceptionpublic boolean hasRequestMetadata()
hasRequestMetadata in class Credentialspublic boolean hasRequestMetadataOnly()
hasRequestMetadataOnly in class CredentialsCopyright © 2022 Google. All rights reserved.