@Beta public final class OAuthParameters extends Object implements HttpExecuteInterceptor, HttpRequestInitializer
Beta
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.
Modifier and Type | Field and Description |
---|---|
String |
callback
Absolute URI back to which the server will redirect the resource owner when the Resource Owner
Authorization step is completed.
|
String |
consumerKey
Required identifier portion of the client credentials (equivalent to a username).
|
String |
nonce
Required nonce value.
|
String |
realm
Realm.
|
String |
signature
Signature.
|
String |
signatureMethod
Name of the signature method used by the client to sign the request.
|
OAuthSigner |
signer
Required OAuth signature algorithm.
|
String |
timestamp
Required timestamp value.
|
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. |
String |
verifier
The verification code received from the server.
|
String |
version
Must either be "1.0" or
null to skip. |
Constructor and Description |
---|
OAuthParameters() |
Modifier and Type | Method and Description |
---|---|
void |
computeNonce()
Computes a nonce based on the hex string of a random non-negative long, setting the value of
the
nonce field. |
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. |
void |
computeTimestamp()
Computes a timestamp based on the current system time, setting the value of the
timestamp field. |
static String |
escape(String value)
Returns the escaped form of the given value using OAuth escaping rules.
|
String |
getAuthorizationHeader()
Returns the
Authorization header value to use with the OAuth parameter values found in
the fields. |
void |
initialize(HttpRequest request) |
void |
intercept(HttpRequest request) |
public OAuthSigner signer
public String callback
public String consumerKey
public String nonce
computeNonce()
.public String realm
public String signature
computeSignature(java.lang.String, com.google.api.client.http.GenericUrl)
.public String signatureMethod
computeSignature(java.lang.String, com.google.api.client.http.GenericUrl)
.public String timestamp
computeTimestamp()
.public String token
null
if the
request is not associated with a resource owner.public String verifier
public String version
null
to skip. Provides the version of the authentication
process as defined in this specification.public void computeNonce()
nonce
field.public void computeTimestamp()
timestamp
field.public void computeSignature(String requestMethod, GenericUrl requestUrl) throws GeneralSecurityException
signature
and signatureMethod
fields.GeneralSecurityException
- general security exceptionpublic String getAuthorizationHeader()
Authorization
header value to use with the OAuth parameter values found in
the fields.public static String escape(String value)
public void initialize(HttpRequest request) throws IOException
initialize
in interface HttpRequestInitializer
IOException
public void intercept(HttpRequest request) throws IOException
intercept
in interface HttpExecuteInterceptor
IOException
Copyright © 2011–2021 Google. All rights reserved.