com.google.api.client.extensions.auth.helpers.oauth2.draft10
Class OAuth2Credential

java.lang.Object
  extended by com.google.api.client.extensions.auth.helpers.oauth2.draft10.OAuth2Credential
All Implemented Interfaces:
Credential, HttpExecuteInterceptor, HttpRequestInitializer, HttpUnsuccessfulResponseHandler, javax.jdo.InstanceCallbacks, javax.jdo.listener.ClearCallback, javax.jdo.listener.DeleteCallback, javax.jdo.listener.LoadCallback, javax.jdo.listener.StoreCallback

Deprecated. (scheduled to be removed in 1.10) Use Credential

@Deprecated
public final class OAuth2Credential
extends Object
implements Credential, javax.jdo.InstanceCallbacks

Credential implementation that is used to authorize OAuth2 enabled requests through the use of the access_token header, as well as refresh the token when it is required. It is important that access to this class be made from within a managed JDO context and that the persistence manager be closed in a finally block to save any updates to the access token. This class is safe to use from multiple threads.

Since:
1.4
Author:
moshenko@google.com (Jacob Moshenko)

Constructor Summary
OAuth2Credential(String userId, String accessToken)
          Deprecated. Create an instance of an OAuth2Credential that can be used to authorize requests on behalf of an end user.
OAuth2Credential(String userId, String accessToken, String refreshToken)
          Deprecated. Create an instance of an OAuth2Credential that can be used to authorize requests on behalf of an end user.
 
Method Summary
 String getAccessToken()
          Deprecated. Return the current access token.
 String getRefreshToken()
          Deprecated. Return the refresh token with which this object was constructed or null for none.
 boolean handleResponse(HttpRequest request, HttpResponse response, boolean retrySupported)
          Deprecated.  
 void initialize(HttpRequest request)
          Deprecated.  
 void initializeForRefresh(String clientId, String clientSecret, String refreshUrl, JsonFactory jsonFactory, HttpTransport transport)
          Deprecated. Initialize the instance with the required information to allow token refresh.
 void intercept(HttpRequest request)
          Deprecated.  
 boolean isInvalid()
          Deprecated. Determine if the Credential is no longer valid, after being revoked for example.
 void jdoPostLoad()
          Deprecated.  
 void jdoPreClear()
          Deprecated.  
 void jdoPreDelete()
          Deprecated.  
 void jdoPreStore()
          Deprecated.  
 boolean refresh(HttpTransport transport, JsonFactory factory)
          Deprecated. Force a refresh of this credential if possible using the HttpTransport and JsonFactory objects provided for the network communication.
 void setAccessToken(String accessToken)
          Deprecated. Sets the access token or null for none.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OAuth2Credential

public OAuth2Credential(String userId,
                        String accessToken,
                        String refreshToken)
Deprecated. 
Create an instance of an OAuth2Credential that can be used to authorize requests on behalf of an end user. Once you construct the object, you must call initializeForRefresh(String, String, String, JsonFactory, HttpTransport) to provide the necessary information to allow token refresh.

Parameters:
userId - Key that can be used to associate this Credential object with an end user.
accessToken - Access token that can be used to authorize this request.
refreshToken - Token that can be given to the token server in exchange for a new access token or null for none.

OAuth2Credential

public OAuth2Credential(String userId,
                        String accessToken)
Deprecated. 
Create an instance of an OAuth2Credential that can be used to authorize requests on behalf of an end user. Instances created through this constructor are not eligible for token refresh.

Parameters:
userId - Key that can be used to associate this Credential object with an end user.
accessToken - Access token that can be used to authorize this request.
Method Detail

refresh

public boolean refresh(HttpTransport transport,
                       JsonFactory factory)
                throws IOException
Deprecated. 
Force a refresh of this credential if possible using the HttpTransport and JsonFactory objects provided for the network communication.

Parameters:
transport - HttpTransport to use for the refresh
factory - JsonFactory to use to parse the auth response
Returns:
Success or failure of refresh operation
Throws:
IOException - When the credential can not communicate with the token server.

initialize

public void initialize(HttpRequest request)
                throws IOException
Deprecated. 
Specified by:
initialize in interface HttpRequestInitializer
Throws:
IOException

intercept

public void intercept(HttpRequest request)
               throws IOException
Deprecated. 
Specified by:
intercept in interface HttpExecuteInterceptor
Throws:
IOException

handleResponse

public boolean handleResponse(HttpRequest request,
                              HttpResponse response,
                              boolean retrySupported)
Deprecated. 
Specified by:
handleResponse in interface HttpUnsuccessfulResponseHandler

initializeForRefresh

public void initializeForRefresh(String clientId,
                                 String clientSecret,
                                 String refreshUrl,
                                 JsonFactory jsonFactory,
                                 HttpTransport transport)
Deprecated. 
Initialize the instance with the required information to allow token refresh. This must be done after construction or after loading the object from the data store.

Parameters:
clientId - Used to identify the client server with the token server.
clientSecret - Secret shared between the client server and the token server.
refreshUrl - Url which can be used to exchange the refresh token for a new access token.
jsonFactory - Json factory used to deserialize communications with the token server.
transport - Transport used to send requests to the token server.

getAccessToken

public String getAccessToken()
Deprecated. 
Return the current access token. This may be either the access token with which the object was constructed, or a token fetched through a successful refresh.


setAccessToken

public void setAccessToken(String accessToken)
Deprecated. 
Sets the access token or null for none.


getRefreshToken

public String getRefreshToken()
Deprecated. 
Return the refresh token with which this object was constructed or null for none. This can be used for out of band use cases, but most users should just let the credential be refreshed by the library when a call fails.


jdoPreClear

public void jdoPreClear()
Deprecated. 
Specified by:
jdoPreClear in interface javax.jdo.listener.ClearCallback

jdoPreDelete

public void jdoPreDelete()
Deprecated. 
Specified by:
jdoPreDelete in interface javax.jdo.listener.DeleteCallback

jdoPostLoad

public void jdoPostLoad()
Deprecated. 
Specified by:
jdoPostLoad in interface javax.jdo.listener.LoadCallback

jdoPreStore

public void jdoPreStore()
Deprecated. 
Specified by:
jdoPreStore in interface javax.jdo.listener.StoreCallback

isInvalid

public boolean isInvalid()
Deprecated. 
Description copied from interface: Credential
Determine if the Credential is no longer valid, after being revoked for example.

Specified by:
isInvalid in interface Credential


Copyright © 2011-2012 Google. All Rights Reserved.