public final class OAuthParameters implements HttpExecuteInterceptor, HttpRequestInitializer
Beta
OAuth 1.0a parameter manager.
The only required non-computed fields are #signer and #consumerKey. Use #token to specify token or temporary credentials.
Sample usage, taking advantage that this class implements HttpRequestInitializer:
public static HttpRequestFactory createRequestFactory(HttpTransport transport) { OAuthParameters parameters = new OAuthParameters(); // ... return transport.createRequestFactory(parameters); }
If you have a custom request initializer, take a look at the sample usage for HttpExecuteInterceptor, which this class also implements.
Implements
com.google.api.client.http.HttpExecuteInterceptor, com.google.api.client.http.HttpRequestInitializerStatic Methods
escape(String value)
public static String escape(String value)
Returns the escaped form of the given value using OAuth escaping rules.
Parameter | |
---|---|
Name | Description |
value |
String |
Returns | |
---|---|
Type | Description |
String |
Constructors
OAuthParameters()
public OAuthParameters()
Fields
callback
public String callback
Absolute URI back to which the server will redirect the resource owner when the Resource Owner Authorization step is completed.
Field Value | |
---|---|
Type | Description |
String |
consumerKey
public String consumerKey
Required identifier portion of the client credentials (equivalent to a username).
Field Value | |
---|---|
Type | Description |
String |
nonce
public String nonce
Required nonce value. Should be computed using #computeNonce().
Field Value | |
---|---|
Type | Description |
String |
realm
public String realm
Realm.
Field Value | |
---|---|
Type | Description |
String |
signature
public String signature
Signature. Required but normally computed using #computeSignature.
Field Value | |
---|---|
Type | Description |
String |
signatureMethod
public String signatureMethod
Name of the signature method used by the client to sign the request. Required, but normally computed using #computeSignature.
Field Value | |
---|---|
Type | Description |
String |
signer
public OAuthSigner signer
Required OAuth signature algorithm.
Field Value | |
---|---|
Type | Description |
OAuthSigner |
timestamp
public String timestamp
Required timestamp value. Should be computed using #computeTimestamp().
Field Value | |
---|---|
Type | Description |
String |
token
public String token
Token value used to associate the request with the resource owner or null
if the
request is not associated with a resource owner.
Field Value | |
---|---|
Type | Description |
String |
verifier
public String verifier
The verification code received from the server.
Field Value | |
---|---|
Type | Description |
String |
version
public String version
Must either be "1.0" or null
to skip. Provides the version of the authentication
process as defined in this specification.
Field Value | |
---|---|
Type | Description |
String |
Methods
computeNonce()
public void computeNonce()
Computes a nonce based on the hex string of a random non-negative long, setting the value of the #nonce field.
computeSignature(String requestMethod, GenericUrl requestUrl)
public void computeSignature(String requestMethod, GenericUrl requestUrl)
Computes a new signature based on the fields and the given request method and URL, setting the values of the #signature and #signatureMethod fields.
Parameters | |
---|---|
Name | Description |
requestMethod |
String |
requestUrl |
com.google.api.client.http.GenericUrl |
Exceptions | |
---|---|
Type | Description |
GeneralSecurityException |
general security exception |
computeTimestamp()
public void computeTimestamp()
Computes a timestamp based on the current system time, setting the value of the #timestamp field.
getAuthorizationHeader()
public String getAuthorizationHeader()
Returns the Authorization
header value to use with the OAuth parameter values found in
the fields.
Returns | |
---|---|
Type | Description |
String |
initialize(HttpRequest request)
public void initialize(HttpRequest request)
Parameter | |
---|---|
Name | Description |
request |
com.google.api.client.http.HttpRequest |
Exceptions | |
---|---|
Type | Description |
IOException |
intercept(HttpRequest request)
public void intercept(HttpRequest request)
Parameter | |
---|---|
Name | Description |
request |
com.google.api.client.http.HttpRequest |
Exceptions | |
---|---|
Type | Description |
IOException |