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("[email protected]")
.setSubject("[email protected]")
.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, getRequestMetadata
public static JwtCredentials.Builder newBuilder()
public void refresh() throws IOException
refresh
in class Credentials
IOException
public JwtCredentials jwtWithClaims(JwtClaims newClaims)
jwtWithClaims
in interface JwtProvider
newClaims
- new claims. Any unspecified claim fields default to the the current values.public String getAuthenticationType()
getAuthenticationType
in class Credentials
public Map<String,List<String>> getRequestMetadata(URI uri) throws IOException
getRequestMetadata
in class Credentials
IOException
public boolean hasRequestMetadata()
hasRequestMetadata
in class Credentials
public boolean hasRequestMetadataOnly()
hasRequestMetadataOnly
in class Credentials
Copyright © 2022 Google. All rights reserved.