Class OAuthParameters
java.lang.Object
com.google.api.client.auth.oauth.OAuthParameters
- All Implemented Interfaces:
com.google.api.client.http.HttpExecuteInterceptor, com.google.api.client.http.HttpRequestInitializer
@Beta
public final class OAuthParameters
extends Object
implements com.google.api.client.http.HttpExecuteInterceptor, com.google.api.client.http.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.
- Since:
- 1.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionAbsolute URI back to which the server will redirect the resource owner when the Resource Owner Authorization step is completed.Required identifier portion of the client credentials (equivalent to a username).private static final com.google.api.client.util.escape.PercentEscaperRequired nonce value.private static final SecureRandomSecure random number generator to sign requests.Realm.Signature.Name of the signature method used by the client to sign the request.Required OAuth signature algorithm.Required timestamp value.Token value used to associate the request with the resource owner ornullif the request is not associated with a resource owner.The verification code received from the server.Must either be "1.0" ornullto skip. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidappendParameter(StringBuilder buf, String name, String value) voidComputes a nonce based on the hex string of a random non-negative long, setting the value of thenoncefield.voidcomputeSignature(String requestMethod, com.google.api.client.http.GenericUrl requestUrl) Computes a new signature based on the fields and the given request method and URL, setting the values of thesignatureandsignatureMethodfields.voidComputes a timestamp based on the current system time, setting the value of thetimestampfield.static StringReturns the escaped form of the given value using OAuth escaping rules.Returns theAuthorizationheader value to use with the OAuth parameter values found in the fields.voidinitialize(com.google.api.client.http.HttpRequest request) voidintercept(com.google.api.client.http.HttpRequest request) private voidprivate void
-
Field Details
-
RANDOM
Secure random number generator to sign requests. -
signer
Required OAuth signature algorithm. -
callback
Absolute URI back to which the server will redirect the resource owner when the Resource Owner Authorization step is completed. -
consumerKey
Required identifier portion of the client credentials (equivalent to a username). -
nonce
Required nonce value. Should be computed usingcomputeNonce(). -
realm
Realm. -
signature
Signature. Required but normally computed usingcomputeSignature(String, GenericUrl). -
signatureMethod
Name of the signature method used by the client to sign the request. Required, but normally computed usingcomputeSignature(String, GenericUrl). -
timestamp
Required timestamp value. Should be computed usingcomputeTimestamp(). -
token
Token value used to associate the request with the resource owner ornullif the request is not associated with a resource owner. -
verifier
The verification code received from the server. -
version
Must either be "1.0" ornullto skip. Provides the version of the authentication process as defined in this specification. -
ESCAPER
private static final com.google.api.client.util.escape.PercentEscaper ESCAPER
-
-
Constructor Details
-
OAuthParameters
public OAuthParameters()
-
-
Method Details
-
computeNonce
public void computeNonce()Computes a nonce based on the hex string of a random non-negative long, setting the value of thenoncefield. -
computeTimestamp
public void computeTimestamp()Computes a timestamp based on the current system time, setting the value of thetimestampfield. -
computeSignature
public void computeSignature(String requestMethod, com.google.api.client.http.GenericUrl requestUrl) throws GeneralSecurityException Computes a new signature based on the fields and the given request method and URL, setting the values of thesignatureandsignatureMethodfields.- Throws:
GeneralSecurityException- general security exception
-
getAuthorizationHeader
Returns theAuthorizationheader value to use with the OAuth parameter values found in the fields. -
appendParameter
-
putParameterIfValueNotNull
-
putParameter
-
escape
-
initialize
- Specified by:
initializein interfacecom.google.api.client.http.HttpRequestInitializer- Throws:
IOException
-
intercept
- Specified by:
interceptin interfacecom.google.api.client.http.HttpExecuteInterceptor- Throws:
IOException
-