Class OAuthHmacThreeLeggedFlow
- java.lang.Object
-
- com.google.api.client.extensions.auth.helpers.oauth.OAuthHmacThreeLeggedFlow
-
- All Implemented Interfaces:
ThreeLeggedFlow
@Beta public class OAuthHmacThreeLeggedFlow extends java.lang.Object implements ThreeLeggedFlow
Beta
ThreeLeggedFlowimplementation that will execute the proper requests to obtain an OAuth1 Credential object that can be used to sign requests.This class is not thread safe, nor should you attempt to execute a flow from multiple threads simultaneously.
- Since:
- 1.5
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringauthorizationServerUrlAuthorization url which we will use to talk to the server.private java.lang.StringauthorizationUrlUrl which is generated to authorize this specific user for this service.private java.lang.StringconsumerKeyKey that identifies the server to the service provider.private java.lang.StringconsumerSecretSecret that is shared between the server and the service provider.private java.lang.StringtempTokenTemporary token that gets associated with this flow.private java.lang.StringtempTokenSecretTemporary secret that gets associated with the temporary token.private com.google.api.client.http.HttpTransporttransportHttp transport to use to communicate with the auth server.private java.lang.StringuserIdKey that can be used to associate this flow with an end user.
-
Constructor Summary
Constructors Constructor Description OAuthHmacThreeLeggedFlow(java.lang.String userId, java.lang.String consumerKey, java.lang.String consumerSecret, java.lang.String authorizationServerUrl, java.lang.String temporaryTokenUrl, java.lang.String callbackUrl, com.google.api.client.http.HttpTransport transport)Create an OAuthThreeLeggedFlow instance from the required information.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Credentialcomplete(java.lang.String authorizationCode)After the user has authorized the request, the token or code obtained should be passed to this complete function to allow us to exchange the code with the authentication server for aCredential.java.lang.StringgetAuthorizationUrl()After the object is created, the developer should use this method to interrogate it for the authorization URL to which the user should be redirected to obtain permission.CredentialloadCredential(javax.jdo.PersistenceManager pm)Convenience function that will load a credential based on the userId for which this flow was instantiated.voidsetHttpTransport(com.google.api.client.http.HttpTransport transport)SetHttpTransportinstance for this three legged flow.voidsetJsonFactory(com.google.api.client.json.JsonFactory jsonFactory)SetJsonFactoryinstance for this three legged flow.
-
-
-
Field Detail
-
userId
private java.lang.String userId
Key that can be used to associate this flow with an end user.
-
tempToken
private java.lang.String tempToken
Temporary token that gets associated with this flow.
-
tempTokenSecret
private java.lang.String tempTokenSecret
Temporary secret that gets associated with the temporary token.
-
consumerSecret
private java.lang.String consumerSecret
Secret that is shared between the server and the service provider.
-
consumerKey
private java.lang.String consumerKey
Key that identifies the server to the service provider.
-
authorizationServerUrl
private java.lang.String authorizationServerUrl
Authorization url which we will use to talk to the server.
-
authorizationUrl
private final java.lang.String authorizationUrl
Url which is generated to authorize this specific user for this service.
-
transport
private com.google.api.client.http.HttpTransport transport
Http transport to use to communicate with the auth server.
-
-
Constructor Detail
-
OAuthHmacThreeLeggedFlow
public OAuthHmacThreeLeggedFlow(java.lang.String userId, java.lang.String consumerKey, java.lang.String consumerSecret, java.lang.String authorizationServerUrl, java.lang.String temporaryTokenUrl, java.lang.String callbackUrl, com.google.api.client.http.HttpTransport transport) throws java.io.IOExceptionCreate an OAuthThreeLeggedFlow instance from the required information.- Parameters:
userId- Key that can be used to associate this flow with an end user.consumerKey- Key that identifies the server to the service provider.consumerSecret- Secret that is shared between the server and the service provider.authorizationServerUrl- Url with which we communicate to authorize tis application.temporaryTokenUrl- Url which we will use to obtain a temporary token.callbackUrl- Url which the server should redirect the user to after obtaining authorization.- Throws:
java.io.IOException- Exception thrown when the flow is unable to communicate with the service provider.
-
-
Method Detail
-
getAuthorizationUrl
public java.lang.String getAuthorizationUrl()
Description copied from interface:ThreeLeggedFlowAfter the object is created, the developer should use this method to interrogate it for the authorization URL to which the user should be redirected to obtain permission.- Specified by:
getAuthorizationUrlin interfaceThreeLeggedFlow- Returns:
- URL to which the user should be directed
-
complete
public Credential complete(java.lang.String authorizationCode) throws java.io.IOException
Description copied from interface:ThreeLeggedFlowAfter the user has authorized the request, the token or code obtained should be passed to this complete function to allow us to exchange the code with the authentication server for aCredential.- Specified by:
completein interfaceThreeLeggedFlow- Parameters:
authorizationCode- Code or token obtained after the user grants permission- Returns:
Credentialobject that is obtained from token server- Throws:
java.io.IOException
-
loadCredential
public Credential loadCredential(javax.jdo.PersistenceManager pm)
Description copied from interface:ThreeLeggedFlowConvenience function that will load a credential based on the userId for which this flow was instantiated.- Specified by:
loadCredentialin interfaceThreeLeggedFlow- Parameters:
pm-PersistenceManagerinstance which this flow should use to interact with the data store. The caller must remember to callPersistenceManager.close()after this method returns.- Returns:
- Fully initialized
Credentialobject ornullif none exists.
-
setHttpTransport
public void setHttpTransport(com.google.api.client.http.HttpTransport transport)
Description copied from interface:ThreeLeggedFlowSetHttpTransportinstance for this three legged flow.- Specified by:
setHttpTransportin interfaceThreeLeggedFlow
-
setJsonFactory
public void setJsonFactory(com.google.api.client.json.JsonFactory jsonFactory)
Description copied from interface:ThreeLeggedFlowSetJsonFactoryinstance for this three legged flow.- Specified by:
setJsonFactoryin interfaceThreeLeggedFlow
-
-