com.google.api.client.googleapis.auth.oauth2.draft10
Class GoogleAccessProtectedResource

java.lang.Object
  extended by com.google.api.client.auth.oauth2.draft10.AccessProtectedResource
      extended by com.google.api.client.googleapis.auth.oauth2.draft10.GoogleAccessProtectedResource
All Implemented Interfaces:
HttpExecuteInterceptor, HttpRequestInitializer, HttpUnsuccessfulResponseHandler

Deprecated. (scheduled to be removed in 1.9) Use GoogleCredential

@Deprecated
public class GoogleAccessProtectedResource
extends AccessProtectedResource

Thread-safe Google extension to the OAuth 2.0 (draft 10) method for specifying and refreshing the access token parameter as a request parameter.

Sample usage, taking advantage that this class implements HttpRequestInitializer:

  public static HttpRequestFactory createRequestFactoryNoRefresh(HttpTransport transport,
      JsonFactory jsonFactory, AccessTokenResponse accessTokenResponse) {
    return transport.createRequestFactory(new GoogleAccessProtectedResource(
        accessTokenResponse.accessToken));
  }

  public static HttpRequestFactory createRequestFactory(HttpTransport transport,
      JsonFactory jsonFactory, AccessTokenResponse accessTokenResponse) {
    return transport.createRequestFactory(new GoogleAccessProtectedResource(
        accessTokenResponse.accessToken, transport, jsonFactory, "s6BhdRkqt3", "gX1fBat3bV",
        accessTokenResponse.refreshToken));
  }
 

If you need to persist the access token in a data store, subclass AccessProtectedResource and override AccessProtectedResource.onAccessToken(String).

If you have a custom request initializer, request execute interceptor, or unsuccessful response handler, take a look at the sample usage for HttpExecuteInterceptor and HttpUnsuccessfulResponseHandler, which are interfaces that this class also implements.

Since:
1.4
Author:
Yaniv Inbar

Nested Class Summary
 
Nested classes/interfaces inherited from class com.google.api.client.auth.oauth2.draft10.AccessProtectedResource
AccessProtectedResource.Method
 
Constructor Summary
GoogleAccessProtectedResource(String accessToken)
          Deprecated.  
GoogleAccessProtectedResource(String accessToken, HttpTransport transport, JsonFactory jsonFactory, String clientId, String clientSecret, String refreshToken)
          Deprecated.  
 
Method Summary
protected  boolean executeRefreshToken()
          Deprecated.  
 
Methods inherited from class com.google.api.client.auth.oauth2.draft10.AccessProtectedResource
executeAccessTokenRequest, getAccessToken, getAuthorizationServerUrl, getClientId, getClientSecret, getJsonFactory, getMethod, getRefreshToken, getTransport, handleResponse, initialize, intercept, onAccessToken, refreshToken, setAccessToken
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GoogleAccessProtectedResource

public GoogleAccessProtectedResource(String accessToken)
Deprecated. 
Parameters:
accessToken - access token or null for none

GoogleAccessProtectedResource

public GoogleAccessProtectedResource(String accessToken,
                                     HttpTransport transport,
                                     JsonFactory jsonFactory,
                                     String clientId,
                                     String clientSecret,
                                     String refreshToken)
Deprecated. 
Parameters:
accessToken - access token or null for none
transport - HTTP transport for executing refresh token request
jsonFactory - JSON factory to use for parsing response for refresh token request
clientId - client identifier
clientSecret - client secret
refreshToken - refresh token associated with the access token to be refreshed or null for none
Method Detail

executeRefreshToken

protected boolean executeRefreshToken()
                               throws IOException
Deprecated. 
Overrides:
executeRefreshToken in class AccessProtectedResource
Throws:
IOException


Copyright © 2010-2012 Google. All Rights Reserved.