Class TokenVerifier.Builder (1.24.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
Type Description
TokenVerifier

the customized TokenVerifier

setAudience(String audience)

public TokenVerifier.Builder setAudience(String audience)

Set a target audience to verify.

Parameter
Name Description
audience String

the audience claim to verify

Returns
Type Description
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
Name Description
certificatesLocation String

URL to published public keys

Returns
Type Description
TokenVerifier.Builder

the builder

setClock(Clock clock)

public TokenVerifier.Builder setClock(Clock clock)

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

Parameter
Name Description
clock com.google.api.client.util.Clock

the clock to use. Defaults to the system clock

Returns
Type Description
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
Name Description
httpTransportFactory HttpTransportFactory

the HttpTransportFactory used to build certificate URL requests

Returns
Type Description
TokenVerifier.Builder

the builder

setIssuer(String issuer)

public TokenVerifier.Builder setIssuer(String issuer)

Set the issuer to verify.

Parameter
Name Description
issuer String

the issuer claim to verify

Returns
Type Description
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
Name Description
publicKey PublicKey

the public key to validate the signature

Returns
Type Description
TokenVerifier.Builder

the builder