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

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.AccessTokenRequest
All Implemented Interfaces:
Cloneable, Map<String,Object>
Direct Known Subclasses:
AccessTokenRequest.AssertionGrant, AccessTokenRequest.AuthorizationCodeGrant, AccessTokenRequest.RefreshTokenGrant, AccessTokenRequest.ResourceOwnerPasswordCredentialsGrant

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

@Deprecated
public class AccessTokenRequest
extends GenericData

OAuth 2.0 request for an access token as specified in Obtaining an Access Token.

This class may be used directly when no access grant is included, such as when the client is requesting access to the protected resources under its control. Otherwise, use one of the subclasses, which add custom parameters to specify the access grant. Call execute() to execute the request from which the AccessTokenResponse may be parsed. On error, use AccessTokenErrorResponse instead.

Sample usage when the client is requesting access to the protected resources under its control:

 
  static void requestAccessToken() throws IOException {
    try {
      AccessTokenRequest request =
          new AccessTokenRequest(new NetHttpTransport(), new JacksonFactory(),
              "https://server.example.com/authorize", "s6BhdRkqt3", "gX1fBat3bV");
      AccessTokenResponse response = request.execute().parseAs(AccessTokenResponse.class);
      System.out.println("Access token: " + response.accessToken);
    } catch (HttpResponseException e) {
      AccessTokenErrorResponse response = e.response.parseAs(AccessTokenErrorResponse.class);
      System.out.println("Error: " + response.error);
    }
  }
 
 

Since:
1.2
Author:
Yaniv Inbar

Nested Class Summary
static class AccessTokenRequest.AssertionGrant
          Deprecated. (scheduled to be removed in 1.5) Use AccessTokenRequest.AssertionGrant
static class AccessTokenRequest.AuthorizationCodeGrant
          Deprecated. (scheduled to be removed in 1.5) Use AccessTokenRequest.AuthorizationCodeGrant
static class AccessTokenRequest.RefreshTokenGrant
          Deprecated. (scheduled to be removed in 1.5) Use AccessTokenRequest.RefreshTokenGrant
static class AccessTokenRequest.ResourceOwnerPasswordCredentialsGrant
          Deprecated. (scheduled to be removed in 1.5) Use AccessTokenRequest.ResourceOwnerPasswordCredentialsGrant
 
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 authorizationServerUrl
          Deprecated. (REQUIRED) Encoded authorization server URL.
 String clientId
          Deprecated. (REQUIRED, unless the client identity can be establish via other means, for example assertion) The client identifier or null for none.
 String clientSecret
          Deprecated. (REQUIRED) The client secret.
 String grantType
          Deprecated. (REQUIRED) The access grant type included in the request.
 JsonFactory jsonFactory
          Deprecated. (REQUIRED) JSON factory to use for parsing response in execute().
 String scope
          Deprecated. (OPTIONAL) The scope of the access request expressed as a list of space-delimited strings or null for none.
 HttpTransport transport
          Deprecated. (REQUIRED) HTTP transport required for executing request in execute().
 boolean useBasicAuthorization
          Deprecated. Defaults to true to use Basic Authentication as recommended in Client Password Credentials, but may be set to false for for specifying the password in the request body using the "clientSecret" parameter in the HTTP body.
 
Fields inherited from class com.google.api.client.util.GenericData
unknownFields
 
Constructor Summary
AccessTokenRequest()
          Deprecated.  
 
Method Summary
 HttpResponse execute()
          Deprecated. Executes request for an access token, and returns the HTTP response.
 
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

transport

public HttpTransport transport
Deprecated. 
(REQUIRED) HTTP transport required for executing request in execute().

Since:
1.3

jsonFactory

public JsonFactory jsonFactory
Deprecated. 
(REQUIRED) JSON factory to use for parsing response in execute().

Since:
1.3

grantType

public String grantType
Deprecated. 
(REQUIRED) The access grant type included in the request. Value MUST be one of "authorization_code", "password", "assertion", "refresh_token", or "none".


clientId

public String clientId
Deprecated. 
(REQUIRED, unless the client identity can be establish via other means, for example assertion) The client identifier or null for none.


clientSecret

public String clientSecret
Deprecated. 
(REQUIRED) The client secret.


scope

public String scope
Deprecated. 
(OPTIONAL) The scope of the access request expressed as a list of space-delimited strings or null for none. 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. If the access grant being used already represents an approved scope (e.g. authorization code, assertion), the requested scope MUST be equal or lesser than the scope previously granted.


authorizationServerUrl

public String authorizationServerUrl
Deprecated. 
(REQUIRED) Encoded authorization server URL.


useBasicAuthorization

public boolean useBasicAuthorization
Deprecated. 
Defaults to true to use Basic Authentication as recommended in Client Password Credentials, but may be set to false for for specifying the password in the request body using the "clientSecret" parameter in the HTTP body.

Constructor Detail

AccessTokenRequest

public AccessTokenRequest()
Deprecated. 
Method Detail

execute

public final HttpResponse execute()
                           throws IOException
Deprecated. 
Executes request for an access token, and returns the HTTP response.

Returns:
HTTP response, which can then be parsed using HttpResponse.parseAs(Class) with AccessTokenResponse
Throws:
HttpResponseException - for an HTTP error response, which can then be parsed using HttpResponse.parseAs(Class) on HttpResponseException.response using AccessTokenErrorResponse
IOException - I/O exception


Copyright © 2010-2011 Google. All Rights Reserved.