public class AuthorizationResponse extends Object
A response to an authorization request.
Modifier and Type | Class and Description |
---|---|
static class |
AuthorizationResponse.Builder
Creates instances of
AuthorizationResponse . |
Modifier and Type | Field and Description |
---|---|
String |
accessToken
The access token retrieved as part of the authorization flow.
|
Long |
accessTokenExpirationTime
The approximate expiration time of the access token, as milliseconds from the UNIX epoch.
|
Map<String,String> |
additionalParameters
The additional, non-standard parameters in the response.
|
String |
authorizationCode
The authorization code generated by the authorization server.
|
static String |
EXTRA_RESPONSE
The extra string used to store an
AuthorizationResponse in an intent by
toIntent() . |
String |
idToken
The id token retrieved as part of the authorization flow.
|
AuthorizationRequest |
request
The authorization request associated with this response.
|
String |
scope
The scope of the returned access token.
|
String |
state
The returned state parameter, which must match the value specified in the request.
|
static String |
TOKEN_TYPE_BEARER
Indicates that a provided access token is a bearer token.
|
String |
tokenType
The type of the retrieved token.
|
Modifier and Type | Method and Description |
---|---|
TokenRequest |
createTokenExchangeRequest()
Creates a follow-up request to exchange a received authorization code for tokens.
|
TokenRequest |
createTokenExchangeRequest(Map<String,String> additionalExchangeParameters)
Creates a follow-up request to exchange a received authorization code for tokens, including
the provided additional parameters.
|
static AuthorizationResponse |
fromIntent(android.content.Intent dataIntent)
Extracts an authorization response from an intent produced by
toIntent() . |
Set<String> |
getScopeSet()
Derives the set of scopes from the consolidated, space-delimited scopes in the
scope field. |
boolean |
hasAccessTokenExpired()
Determines whether the returned access token has expired.
|
static AuthorizationResponse |
jsonDeserialize(org.json.JSONObject json)
Reads an authorization response from a JSON string representation produced by
jsonSerialize() . |
static AuthorizationResponse |
jsonDeserialize(String jsonStr)
Reads an authorization request from a JSON string representation produced by
jsonSerializeString() . |
org.json.JSONObject |
jsonSerialize()
Produces a JSON representation of the authorization response for persistent storage or local
transmission (e.g.
|
String |
jsonSerializeString()
Produces a JSON representation of the authorization response for persistent storage or local
transmission (e.g.
|
android.content.Intent |
toIntent()
Produces an intent containing this authorization response.
|
public static final String EXTRA_RESPONSE
The extra string used to store an AuthorizationResponse
in an intent by
toIntent()
.
public static final String TOKEN_TYPE_BEARER
Indicates that a provided access token is a bearer token.
@NonNull public final AuthorizationRequest request
The authorization request associated with this response.
@Nullable public final String state
The returned state parameter, which must match the value specified in the request. AppAuth for Android ensures that this is the case.
@Nullable public final String tokenType
The type of the retrieved token. Typically this is “Bearer” when present. Otherwise, another token_type value that the Client has negotiated with the Authorization Server.
@Nullable public final String authorizationCode
The authorization code generated by the authorization server. Set when the response_type requested includes ‘code’.
@Nullable public final String accessToken
The access token retrieved as part of the authorization flow.
This is available when the response_type
of the request included ‘token’.
@Nullable public final Long accessTokenExpirationTime
The approximate expiration time of the access token, as milliseconds from the UNIX epoch.
Set when the requested response_type
included ‘token’.
@Nullable public final String idToken
The id token retrieved as part of the authorization flow.
This is available when the response_type
of the request included ‘id_token’.
@Nullable public final String scope
The scope of the returned access token. If this is not specified, the scope is assumed to be the same as what was originally requested.
public boolean hasAccessTokenExpired()
Determines whether the returned access token has expired.
@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
.
@NonNull public TokenRequest createTokenExchangeRequest()
Creates a follow-up request to exchange a received authorization code for tokens.
@NonNull public TokenRequest createTokenExchangeRequest(@NonNull Map<String,String> additionalExchangeParameters)
Creates a follow-up request to exchange a received authorization code for tokens, including the provided additional parameters.
@NonNull public org.json.JSONObject jsonSerialize()
Produces a JSON representation of the authorization response for persistent storage or local transmission (e.g. between activities).
@NonNull public String jsonSerializeString()
Produces a JSON representation of the authorization 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 AuthorizationResponse jsonDeserialize(@NonNull org.json.JSONObject json) throws org.json.JSONException
Reads an authorization response from a JSON string representation produced by
jsonSerialize()
.
org.json.JSONException
- if the provided JSON does not match the expected structure.@NonNull public static AuthorizationResponse jsonDeserialize(@NonNull String jsonStr) throws org.json.JSONException
Reads an authorization 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.@NonNull public android.content.Intent toIntent()
Produces an intent containing this authorization response. This is used to deliver the
authorization response to the registered handler after a call to
AuthorizationService.performAuthorizationRequest(net.openid.appauth.AuthorizationRequest, android.app.PendingIntent)
.
@Nullable public static AuthorizationResponse fromIntent(@NonNull android.content.Intent dataIntent)
Extracts an authorization response from an intent produced by toIntent()
. This is
used to extract the response from the intent data passed to an activity registered as the
handler for AuthorizationService.performAuthorizationRequest(net.openid.appauth.AuthorizationRequest, android.app.PendingIntent)
.