public class TokenRequest
extends java.lang.Object
An OAuth2 token request. These are used to exchange codes for tokens, or exchange a refresh token for updated tokens.
| Modifier and Type | Class and Description |
|---|---|
static class |
TokenRequest.Builder
Creates instances of
TokenRequest. |
| Modifier and Type | Field and Description |
|---|---|
java.util.Map<java.lang.String,java.lang.String> |
additionalParameters
Additional parameters to be passed as part of the request.
|
java.lang.String |
authorizationCode
An authorization code to be exchanged for one or more tokens.
|
java.lang.String |
clientId
The client identifier.
|
java.lang.String |
codeVerifier
The code verifier that was used to generate the challenge in the original authorization
request, if one was used.
|
AuthorizationServiceConfiguration |
configuration
The service’s
configuration. |
static java.lang.String |
GRANT_TYPE_CLIENT_CREDENTIALS
The grant type used when requesting an access token using client credentials, typically
TLS client certificates.
|
static java.lang.String |
GRANT_TYPE_PASSWORD
The grant type used when requesting an access token using a username and password.
|
java.lang.String |
grantType
The type of token being sent to the token endpoint.
|
static java.lang.String |
PARAM_CLIENT_ID |
android.net.Uri |
redirectUri
The client’s redirect URI.
|
java.lang.String |
refreshToken
A refresh token to be exchanged for a new token.
|
java.lang.String |
scope
A space-delimited set of scopes used to determine the scope of any returned tokens.
|
| Modifier and Type | Method and Description |
|---|---|
java.util.Map<java.lang.String,java.lang.String> |
getRequestParameters()
Produces the set of request parameters for this query, which can be further
processed into a request body.
|
java.util.Set<java.lang.String> |
getScopeSet()
Derives the set of scopes from the consolidated, space-delimited scopes in the
scope field. |
static TokenRequest |
jsonDeserialize(org.json.JSONObject json)
Reads a token request from a JSON string representation produced by
jsonSerialize(). |
static TokenRequest |
jsonDeserialize(java.lang.String json)
Reads a token request from a JSON string representation produced by
jsonSerializeString(). |
org.json.JSONObject |
jsonSerialize()
Produces a JSON string representation of the token request for persistent storage or
local transmission (e.g.
|
java.lang.String |
jsonSerializeString()
Produces a JSON string representation of the token request for persistent storage or
local transmission (e.g.
|
public static final java.lang.String PARAM_CLIENT_ID
public static final java.lang.String GRANT_TYPE_PASSWORD
The grant type used when requesting an access token using a username and password. This grant type is not directly supported by this library.
public static final java.lang.String GRANT_TYPE_CLIENT_CREDENTIALS
The grant type used when requesting an access token using client credentials, typically TLS client certificates. This grant type is not directly supported by this library.
@NonNull public final AuthorizationServiceConfiguration configuration
The service’s configuration.
This configuration specifies how to connect to a particular OAuth provider.
Configurations may be
created manually, or
via an OpenID Connect Discovery Document.
@NonNull public final java.lang.String clientId
The client identifier.
@NonNull public final java.lang.String grantType
The type of token being sent to the token endpoint.
@Nullable public final android.net.Uri redirectUri
The client’s redirect URI. Required if this token request is to exchange an authorization code for one or more tokens, and must be identical to the value specified in the original authorization request.
@Nullable public final java.lang.String authorizationCode
An authorization code to be exchanged for one or more tokens.
@Nullable public final java.lang.String scope
A space-delimited set of scopes used to determine the scope of any returned tokens.
@Nullable public final java.lang.String refreshToken
A refresh token to be exchanged for a new token.
@Nullable public final java.lang.String codeVerifier
The code verifier that was used to generate the challenge in the original authorization request, if one was used.
@NonNull public final java.util.Map<java.lang.String,java.lang.String> additionalParameters
Additional parameters to be passed as part of the request.
@Nullable public java.util.Set<java.lang.String> getScopeSet()
Derives the set of scopes from the consolidated, space-delimited scopes in the
scope field. If no scopes were specified for this request, the method will
return null.
@NonNull public java.util.Map<java.lang.String,java.lang.String> getRequestParameters()
Produces the set of request parameters for this query, which can be further processed into a request body.
@NonNull public org.json.JSONObject jsonSerialize()
Produces a JSON string representation of the token request for persistent storage or local transmission (e.g. between activities).
@NonNull public java.lang.String jsonSerializeString()
Produces a JSON string representation of the token request 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 TokenRequest jsonDeserialize(org.json.JSONObject json) throws org.json.JSONException
Reads a token request from a JSON string representation produced by
jsonSerialize().
org.json.JSONException - if the provided JSON does not match the expected structure.@NonNull public static TokenRequest jsonDeserialize(@NonNull java.lang.String json) throws org.json.JSONException
Reads a token request from a JSON string representation produced by
jsonSerializeString(). This method is just a convenience wrapper for
jsonDeserialize(JSONObject), converting the JSON string to its JSON object form.
org.json.JSONException - if the provided JSON does not match the expected structure.