Class JwtClaims (1.39.1)

publicabstractclass JwtClaimsimplementsSerializable

Value class representing the set of fields used as the payload of a JWT token.

To create and customize claims, use the builder:


Claimsclaims=Claims.newBuilder()
.setAudience("https://example.com/some-audience")
.setIssuer("some-issuer@example.com")
.setSubject("some-subject@example.com")
.build();

Inheritance

java.lang.Object > JwtClaims

Implements

Serializable

Static Methods

newBuilder()

publicstaticJwtClaims.BuildernewBuilder()
Returns
Type Description
JwtClaims.Builder

Constructors

JwtClaims()

publicJwtClaims()

Methods

isComplete()

publicbooleanisComplete()

Returns whether or not this set of claims is complete.

Audience, issuer, and subject are required to be set in order to use the claim set for a JWT token. An incomplete Claims instance is useful for overriding claims when using ServiceAccountJwtAccessCredentials#jwtWithClaims(JwtClaims) or JwtCredentials#jwtWithClaims(JwtClaims).

Returns
Type Description
boolean

true if all required fields have been set; false otherwise

merge(JwtClaims other)

publicJwtClaimsmerge(JwtClaimsother)

Returns a new Claims instance with overridden fields.

Any non-null field will overwrite the value from the original claims instance.

Parameter
Name Description
other JwtClaims

claims to override

Returns
Type Description
JwtClaims

new claims

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025年10月30日 UTC.