com.google.api.client.auth.oauth2
Class AuthorizationResponse

java.lang.Object
  extended by java.util.AbstractMap<String,Object>
      extended by com.google.api.client.util.GenericData
          extended by com.google.api.client.auth.oauth2.AuthorizationResponse
All Implemented Interfaces:
Cloneable, Map<String,Object>

Deprecated. (scheduled to be removed in 1.5) Use AuthorizationResponse

@Deprecated
public class AuthorizationResponse
extends GenericData

OAuth 2.0 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);
  }
 

Since:
1.2
Author:
Yaniv Inbar

Nested Class Summary
static class AuthorizationResponse.KnownError
          Deprecated. 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
          Deprecated. (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
          Deprecated. (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
          Deprecated. (REQUIRED if the end user denies authorization) A single error code.
 String errorDescription
          Deprecated. (OPTIONAL) A human-readable text providing additional information, used to assist in the understanding and resolution of the error occurred.
 String errorUri
          Deprecated. (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
          Deprecated. (OPTIONAL) The duration in seconds of the access token lifetime if an access token is included.
 String scope
          Deprecated. (OPTIONAL) The scope of the access token as a list of space- delimited strings if an access token is included.
 String state
          Deprecated. (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.util.GenericData
unknownFields
 
Constructor Summary
AuthorizationResponse(String redirectUrl)
          Deprecated.  
 
Method Summary
 AuthorizationResponse.KnownError getErrorCodeIfKnown()
          Deprecated. 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.util.GenericData
clone, entrySet, get, put, putAll, remove, set
 
Methods inherited from class java.util.AbstractMap
clear, containsKey, containsValue, equals, hashCode, isEmpty, keySet, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

code

public String code
Deprecated. 
(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. The authorization code SHOULD expire shortly after it is issued. The authorization server MUST invalidate the authorization code after a single usage. The authorization code is bound to the client identifier and redirection URI.


accessToken

public String accessToken
Deprecated. 
(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.


expiresIn

public Long expiresIn
Deprecated. 
(OPTIONAL) The duration in seconds of the access token lifetime if an access token is included. For example, the value "3600" denotes that the access token will expire in one hour from the time the response was generated by the authorization server.


scope

public String scope
Deprecated. 
(OPTIONAL) The scope of the access token as a list of space- delimited strings if an access token is included. The value of the "scope" parameter is defined by the authorization server. If the value contains multiple space-delimited strings, their order does not matter, and each string adds an additional access range to the requested scope. The authorization server SHOULD include the parameter if the requested scope is different from the one requested by the client.


error

public String error
Deprecated. 
(REQUIRED if the end user denies authorization) A single error code.

See Also:
getErrorCodeIfKnown()

errorDescription

public String errorDescription
Deprecated. 
(OPTIONAL) A human-readable text providing additional information, used to assist in the understanding and resolution of the error occurred.


errorUri

public String errorUri
Deprecated. 
(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.


state

public String state
Deprecated. 
(REQUIRED if the "state" parameter was present in the client authorization request) Set to the exact value received from the client.

Constructor Detail

AuthorizationResponse

public AuthorizationResponse(String redirectUrl)
Deprecated. 
Parameters:
redirectUrl - encoded redirect URL
Throws:
IllegalArgumentException - URI syntax exception
Method Detail

getErrorCodeIfKnown

public final AuthorizationResponse.KnownError getErrorCodeIfKnown()
Deprecated. 
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.



Copyright © 2010-2011 Google. All Rights Reserved.