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 TokenResponse
build()
Creates the token response instance.TokenResponse.Builder
fromResponseJson(JSONObject json)
Extracts token response fields from a JSON object.TokenResponse.Builder
fromResponseJsonString(String jsonStr)
Extracts token response fields from a JSON string.TokenResponse.Builder
setAccessToken(String accessToken)
Specifies the access token.TokenResponse.Builder
setAccessTokenExpirationTime(Long expiresAt)
Sets the exact expiration time of the access token, in milliseconds since the UNIX epoch.TokenResponse.Builder
setAccessTokenExpiresIn(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.Builder
setAdditionalParameters(Map<String,String> additionalParameters)
Specifies the additional, non-standard parameters received as part of the response.TokenResponse.Builder
setIdToken(String idToken)
Specifies the ID token.TokenResponse.Builder
setRefreshToken(String refreshToken)
Specifies the refresh token.TokenResponse.Builder
setRequest(TokenRequest request)
Specifies the request associated with this response.TokenResponse.Builder
setScope(String scope)
Specifies the encoded scope string, which is a space-delimited set of case-sensitive scope identifiers.TokenResponse.Builder
setScopes(Iterable<String> scopes)
Specifies the set of case-sensitive scopes.TokenResponse.Builder
setScopes(String... scopes)
Specifies the set of case-sensitive scopes.TokenResponse.Builder
setTokenType(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.
-
-