Class TokenResponse
- java.lang.Object
-
- net.openid.appauth.TokenResponse
-
public class TokenResponse extends Object
A response to a token request.- See Also:
TokenRequest
,“The OAuth 2.0 Authorization Framework (RFC 6749), Section 4.1.4 https://tools.ietf.org/html/rfc6749#section-4.1.4”
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TokenResponse.Builder
Creates instances ofTokenResponse
.
-
Field Summary
Fields Modifier and Type Field Description String
accessToken
The access token, if provided.Long
accessTokenExpirationTime
The expiration time of the access token, if provided.Map<String,String>
additionalParameters
Additional, non-standard parameters in the response.String
idToken
The ID token describing the authenticated user, if provided.String
refreshToken
The refresh token, if provided.TokenRequest
request
The token request associated with this response.String
scope
The scope of the access token.static String
TOKEN_TYPE_BEARER
Indicates that a provided access token is a bearer token.String
tokenType
The type of the token returned.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Set<String>
getScopeSet()
Derives the set of scopes from the consolidated, space-delimited scopes in thescope
field.static TokenResponse
jsonDeserialize(String jsonStr)
Reads a token response from a JSON string, and associates it with the provided request.static TokenResponse
jsonDeserialize(JSONObject json)
Reads a token response from a JSON string, and associates it with the provided request.JSONObject
jsonSerialize()
Produces a JSON string representation of the token response for persistent storage or local transmission (e.g.String
jsonSerializeString()
Produces a JSON string representation of the token response for persistent storage or local transmission (e.g.
-
-
-
Field Detail
-
TOKEN_TYPE_BEARER
public static final String TOKEN_TYPE_BEARER
Indicates that a provided access token is a bearer token.- See Also:
“The OAuth 2.0 Authorization Framework (RFC 6749), Section 7.1 https://tools.ietf.org/html/rfc6749#section-7.1”
, Constant Field Values
-
request
@NonNull public final TokenRequest request
The token request associated with this response.
-
tokenType
@Nullable public final String tokenType
The type of the token returned.Typically this is
TOKEN_TYPE_BEARER
, or some other token type that the client has negotiated with the authorization service.- See Also:
“The OAuth 2.0 Authorization Framework (RFC 6749), Section 4.1.4 https://tools.ietf.org/html/rfc6749#section-4.1.4”
,“The OAuth 2.0 Authorization Framework (RFC 6749), Section 5.1 https://tools.ietf.org/html/rfc6749#section-5.1”
-
accessToken
@Nullable public final String accessToken
The access token, if provided.- See Also:
“The OAuth 2.0 Authorization Framework (RFC 6749), Section 5.1 https://tools.ietf.org/html/rfc6749#section-5.1”
-
accessTokenExpirationTime
@Nullable public final Long accessTokenExpirationTime
The expiration time of the access token, if provided.If an access token is provided but the expiration time is not, then the expiration time is typically some default value specified by the identity provider through some other means, such as documentation or an additional non-standard field.
-
idToken
@Nullable public final String idToken
The ID token describing the authenticated user, if provided.- See Also:
“OpenID Connect Core 1.0, Section 2 https://openid.net/specs/openid-connect-core-1_0.html#rfc.section.2”
-
refreshToken
@Nullable public final String refreshToken
The refresh token, if provided.- See Also:
“The OAuth 2.0 Authorization Framework (RFC 6749), Section 5.1 https://tools.ietf.org/html/rfc6749#section-5.1”
-
scope
@Nullable public final String scope
The scope of the access token.If the scope is identical to that originally requested, then this value is optional.
- See Also:
“The OAuth 2.0 Authorization Framework (RFC 6749), Section 5.1 https://tools.ietf.org/html/rfc6749#section-5.1”
-
additionalParameters
@NonNull public final Map<String,String> additionalParameters
Additional, non-standard parameters in the response.
-
-
Method Detail
-
getScopeSet
@Nullable public Set<String> getScopeSet()
Derives the set of scopes from the consolidated, space-delimited scopes in thescope
field.If no scopes were specified on this response, the method will return
null
.
-
jsonSerialize
public JSONObject jsonSerialize()
Produces a JSON string representation of the token response for persistent storage or local transmission (e.g.between activities).
-
jsonSerializeString
public String jsonSerializeString()
Produces a JSON string representation of the token response for persistent storage or local transmission (e.g.between activities). This method is just a convenience wrapper for
jsonSerialize()
, converting the JSON object to its string form.
-
jsonDeserialize
@NonNull public static TokenResponse jsonDeserialize(@NonNull JSONObject json) throws JSONException
Reads a token response from a JSON string, and associates it with the provided request.If a request is not provided, its serialized form is expected to be found in the JSON (as if produced by a prior call to
jsonSerialize()
.- Throws:
JSONException
- if the JSON is malformed or missing required fields.
-
jsonDeserialize
@NonNull public static TokenResponse jsonDeserialize(@NonNull String jsonStr) throws JSONException
Reads a token response from a JSON string, and associates it with the provided request.If a request is not provided, its serialized form is expected to be found in the JSON (as if produced by a prior call to
jsonSerialize()
.- Throws:
JSONException
- if the JSON is malformed or missing required fields.
-
-