Class TokenVerifier.Builder (1.7.0)

public static class TokenVerifier.Builder

Inheritance

java.lang.Object > TokenVerifier.Builder

Constructors

Builder()

public Builder()

Methods

build()

public TokenVerifier build()

Build the custom TokenVerifier for verifying tokens.

Returns
TypeDescription
TokenVerifier

the customized TokenVerifier

setAudience(String audience)

public TokenVerifier.Builder setAudience(String audience)

Set a target audience to verify.

Parameter
NameDescription
audienceString

the audience claim to verify

Returns
TypeDescription
TokenVerifier.Builder

the builder

setCertificatesLocation(String certificatesLocation)

public TokenVerifier.Builder setCertificatesLocation(String certificatesLocation)

Override the location URL that contains published public keys. Defaults to well-known Google locations.

Parameter
NameDescription
certificatesLocationString

URL to published public keys

Returns
TypeDescription
TokenVerifier.Builder

the builder

setClock(Clock clock)

public TokenVerifier.Builder setClock(Clock clock)

Set the clock for checking token expiry. Used for testing.

Parameter
NameDescription
clockcom.google.api.client.util.Clock

the clock to use. Defaults to the system clock

Returns
TypeDescription
TokenVerifier.Builder

the builder

setHttpTransportFactory(HttpTransportFactory httpTransportFactory)

public TokenVerifier.Builder setHttpTransportFactory(HttpTransportFactory httpTransportFactory)

Set the HttpTransportFactory used for requesting public keys from the certificate URL. Used mostly for testing.

Parameter
NameDescription
httpTransportFactoryHttpTransportFactory

the HttpTransportFactory used to build certificate URL requests

Returns
TypeDescription
TokenVerifier.Builder

the builder

setIssuer(String issuer)

public TokenVerifier.Builder setIssuer(String issuer)

Set the issuer to verify.

Parameter
NameDescription
issuerString

the issuer claim to verify

Returns
TypeDescription
TokenVerifier.Builder

the builder

setPublicKey(PublicKey publicKey)

public TokenVerifier.Builder setPublicKey(PublicKey publicKey)

Set the PublicKey for verifying the signature. This will ignore the key id from the JWT token header.

Parameter
NameDescription
publicKeyPublicKey

the public key to validate the signature

Returns
TypeDescription
TokenVerifier.Builder

the builder