|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.AbstractMap<String,Object>
com.google.api.client.util.GenericData
com.google.api.client.json.GenericJson
com.google.api.client.auth.oauth2.draft10.AuthorizationResponse
public class AuthorizationResponse
OAuth 2.0 (draft 10) parser for the redirect URL after end user grants or denies authorization as specified in Authorization Response.
Check if error is null to check if the end-user granted authorization.
Sample usage for a web application:
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
StringBuffer fullUrlBuf = request.getRequestURL();
if (request.getQueryString() != null) {
fullUrlBuf.append('?').append(request.getQueryString());
}
AuthorizationResponse authResponse = new AuthorizationResponse(fullUrlBuf.toString());
// check for user-denied error
if (authResponse.error != null) {
// authorization denied...
} else {
// request access token using authResponse.code...
}
}
Sample usage for an installed application:
static void processRedirectUrl(HttpTransport transport, String redirectUrl) {
AuthorizationResponse response = new AuthorizationResponse(redirectUrl);
if (response.error != null) {
throw new RuntimeException("Authorization denied");
}
AccessProtectedResource.usingAuthorizationHeader(transport, response.accessToken);
}
| Nested Class Summary | |
|---|---|
static class |
AuthorizationResponse.KnownError
Error codes listed in Error Codes. |
| Nested classes/interfaces inherited from class java.util.AbstractMap |
|---|
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V> |
| Nested classes/interfaces inherited from interface java.util.Map |
|---|
Map.Entry<K,V> |
| Field Summary | |
|---|---|
String |
accessToken
(REQUIRED if the end user grants authorization and the response type is "token" or "code_and_token", otherwise MUST NOT be included) The access token issued by the authorization server. |
String |
code
(REQUIRED if the end user grants authorization and the response type is "code" or "code_and_token", otherwise MUST NOT be included) The authorization code generated by the authorization server. |
String |
error
(REQUIRED if the end user denies authorization) A single error code. |
String |
errorDescription
(OPTIONAL) A human-readable text providing additional information, used to assist in the understanding and resolution of the error occurred. |
String |
errorUri
(OPTIONAL) A URI identifying a human-readable web page with information about the error, used to provide the end-user with additional information about the error. |
Long |
expiresIn
(OPTIONAL) The duration in seconds of the access token lifetime if an access token is included. |
String |
scope
(OPTIONAL) The scope of the access token as a list of space- delimited strings if an access token is included. |
String |
state
(REQUIRED if the "state" parameter was present in the client authorization request) Set to the exact value received from the client. |
| Fields inherited from class com.google.api.client.json.GenericJson |
|---|
jsonFactory |
| Fields inherited from class com.google.api.client.util.GenericData |
|---|
unknownFields |
| Constructor Summary | |
|---|---|
AuthorizationResponse(String redirectUrl)
|
|
| Method Summary | |
|---|---|
AuthorizationResponse.KnownError |
getErrorCodeIfKnown()
Returns a known error code if error is one of the error codes listed in the OAuth 2
specification or null if the error is null or not known. |
| Methods inherited from class com.google.api.client.json.GenericJson |
|---|
clone, toString |
| Methods inherited from class com.google.api.client.util.GenericData |
|---|
entrySet, get, put, putAll, remove, set |
| Methods inherited from class java.util.AbstractMap |
|---|
clear, containsKey, containsValue, equals, hashCode, isEmpty, keySet, size, values |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public String code
public String accessToken
public Long expiresIn
public String scope
public String error
getErrorCodeIfKnown()public String errorDescription
public String errorUri
public String state
| Constructor Detail |
|---|
public AuthorizationResponse(String redirectUrl)
redirectUrl - encoded redirect URL
IllegalArgumentException - URI syntax exception| Method Detail |
|---|
public final AuthorizationResponse.KnownError getErrorCodeIfKnown()
error is one of the error codes listed in the OAuth 2
specification or null if the error is null or not known.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||