public class TokenResponse extends Object
A response to a token request.
| Modifier and Type | Class and Description |
|---|---|
static class |
TokenResponse.Builder
Creates instances of
TokenResponse. |
| Modifier and Type | Field and 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.
|
| Modifier and Type | Method and Description |
|---|---|
Set<String> |
getScopeSet()
Derives the set of scopes from the consolidated, space-delimited scopes in the
scope field. |
static TokenResponse |
jsonDeserialize(org.json.JSONObject json)
Reads a token response from a JSON string, and associates it with the provided request.
|
static TokenResponse |
jsonDeserialize(String jsonStr)
Reads a token response from a JSON string, and associates it with the provided request.
|
org.json.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.
|
public static final String TOKEN_TYPE_BEARER
Indicates that a provided access token is a bearer token.
@NonNull public final TokenRequest request
The token request associated with this response.
@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.
@Nullable public final String accessToken
The access token, if provided.
@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.
@Nullable public final String idToken
The ID token describing the authenticated user, if provided.
@Nullable public final String refreshToken
The refresh token, if provided.
@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.
@Nullable public Set<String> getScopeSet()
Derives the set of scopes from the consolidated, space-delimited scopes in the
scope field. If no scopes were specified on this response, the method will
return null.
public org.json.JSONObject jsonSerialize()
Produces a JSON string representation of the token response for persistent storage or local transmission (e.g. between activities).
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.
@NonNull public static TokenResponse jsonDeserialize(@NonNull org.json.JSONObject json) throws org.json.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().
org.json.JSONException - if the JSON is malformed or missing required fields.@NonNull public static TokenResponse jsonDeserialize(@NonNull String jsonStr) throws org.json.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().
org.json.JSONException - if the JSON is malformed or missing required fields.