Class TokenResponse.Builder
- java.lang.Object
-
- net.openid.appauth.TokenResponse.Builder
-
- Enclosing class:
- TokenResponse
public static final class TokenResponse.Builder extends Object
Creates instances ofTokenResponse.
-
-
Constructor Summary
Constructors Constructor Description Builder(TokenRequest request)Creates a token response associated with the specified request.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TokenResponsebuild()Creates the token response instance.TokenResponse.BuilderfromResponseJson(JSONObject json)Extracts token response fields from a JSON object.TokenResponse.BuilderfromResponseJsonString(String jsonStr)Extracts token response fields from a JSON string.TokenResponse.BuildersetAccessToken(String accessToken)Specifies the access token.TokenResponse.BuildersetAccessTokenExpirationTime(Long expiresAt)Sets the exact expiration time of the access token, in milliseconds since the UNIX epoch.TokenResponse.BuildersetAccessTokenExpiresIn(Long expiresIn)Sets the relative expiration time of the access token, in seconds, using the default system clock as the source of the current time.TokenResponse.BuildersetAdditionalParameters(Map<String,String> additionalParameters)Specifies the additional, non-standard parameters received as part of the response.TokenResponse.BuildersetIdToken(String idToken)Specifies the ID token.TokenResponse.BuildersetRefreshToken(String refreshToken)Specifies the refresh token.TokenResponse.BuildersetRequest(TokenRequest request)Specifies the request associated with this response.TokenResponse.BuildersetScope(String scope)Specifies the encoded scope string, which is a space-delimited set of case-sensitive scope identifiers.TokenResponse.BuildersetScopes(Iterable<String> scopes)Specifies the set of case-sensitive scopes.TokenResponse.BuildersetScopes(String... scopes)Specifies the set of case-sensitive scopes.TokenResponse.BuildersetTokenType(String tokenType)Specifies the token type of the access token in this response.
-
-
-
Constructor Detail
-
Builder
public Builder(@NonNull TokenRequest request)
Creates a token response associated with the specified request.
-
-
Method Detail
-
fromResponseJsonString
@NonNull public TokenResponse.Builder fromResponseJsonString(@NonNull String jsonStr) throws JSONException
Extracts token response fields from a JSON string.- Throws:
JSONException- if the JSON is malformed or has incorrect value types for fields.
-
fromResponseJson
@NonNull public TokenResponse.Builder fromResponseJson(@NonNull JSONObject json) throws JSONException
Extracts token response fields from a JSON object.- Throws:
JSONException- if the JSON is malformed or has incorrect value types for fields.
-
setRequest
@NonNull public TokenResponse.Builder setRequest(@NonNull TokenRequest request)
Specifies the request associated with this response.Must not be null.
-
setTokenType
@NonNull public TokenResponse.Builder setTokenType(@Nullable String tokenType)
Specifies the token type of the access token in this response.If not null, the value must be non-empty.
-
setAccessToken
@NonNull public TokenResponse.Builder setAccessToken(@Nullable String accessToken)
Specifies the access token.If not null, the value must be non-empty.
-
setAccessTokenExpiresIn
@NonNull public TokenResponse.Builder setAccessTokenExpiresIn(@NonNull Long expiresIn)
Sets the relative expiration time of the access token, in seconds, using the default system clock as the source of the current time.
-
setAccessTokenExpirationTime
@NonNull public TokenResponse.Builder setAccessTokenExpirationTime(@Nullable Long expiresAt)
Sets the exact expiration time of the access token, in milliseconds since the UNIX epoch.
-
setIdToken
public TokenResponse.Builder setIdToken(@Nullable String idToken)
Specifies the ID token.If not null, the value must be non-empty.
-
setRefreshToken
public TokenResponse.Builder setRefreshToken(@Nullable String refreshToken)
Specifies the refresh token.If not null, the value must be non-empty.
-
setScope
@NonNull public TokenResponse.Builder setScope(@Nullable String scope)
Specifies the encoded scope string, which is a space-delimited set of case-sensitive scope identifiers.Replaces any previously specified scope.
- See Also:
“The OAuth 2.0 Authorization Framework (RFC 6749), Section 3.3 https://tools.ietf.org/html/rfc6749#section-3.3”
-
setScopes
@NonNull public TokenResponse.Builder setScopes(String... scopes)
Specifies the set of case-sensitive scopes.Replaces any previously specified set of scopes. Individual scope strings cannot be null or empty.
Scopes specified here are used to obtain a "down-scoped" access token, where the set of scopes specified _must_ be a subset of those already granted in previous requests.
- See Also:
“The OAuth 2.0 Authorization Framework (RFC 6749), Section 3.3 https://tools.ietf.org/html/rfc6749#section-3.3”,“The OAuth 2.0 Authorization Framework (RFC 6749), Section 6 https://tools.ietf.org/html/rfc6749#section-6”
-
setScopes
@NonNull public TokenResponse.Builder setScopes(@Nullable Iterable<String> scopes)
Specifies the set of case-sensitive scopes.Replaces any previously specified set of scopes. Individual scope strings cannot be null or empty.
Scopes specified here are used to obtain a "down-scoped" access token, where the set of scopes specified _must_ be a subset of those already granted in previous requests.
- See Also:
“The OAuth 2.0 Authorization Framework (RFC 6749), Section 3.3 https://tools.ietf.org/html/rfc6749#section-3.3”,“The OAuth 2.0 Authorization Framework (RFC 6749), Section 6 https://tools.ietf.org/html/rfc6749#section-6”
-
setAdditionalParameters
@NonNull public TokenResponse.Builder setAdditionalParameters(@Nullable Map<String,String> additionalParameters)
Specifies the additional, non-standard parameters received as part of the response.
-
build
public TokenResponse build()
Creates the token response instance.
-
-