pub struct Builder<'a, SM, C = String, T = C> { /* private fields */ }Expand description
A builder for OAuth Authorization header string.
Implementations§
Source§impl<'a, SM: SignatureMethod, C: AsRef<str>, T: AsRef<str>> Builder<'a, SM, C, T>
impl<'a, SM: SignatureMethod, C: AsRef<str>, T: AsRef<str>> Builder<'a, SM, C, T>
Sourcepub fn new(client: Credentials<C>, signature_method: SM) -> Self
pub fn new(client: Credentials<C>, signature_method: SM) -> Self
Creates a Builder that signs requests using the specified client credentials
and signature method.
Sourcepub fn with_token(token: Token<C, T>, signature_method: SM) -> Self
pub fn with_token(token: Token<C, T>, signature_method: SM) -> Self
Creates a Builder that uses the token credentials from token.
Sourcepub fn token(&mut self, token: impl Into<Option<Credentials<T>>>) -> &mut Self
pub fn token(&mut self, token: impl Into<Option<Credentials<T>>>) -> &mut Self
Sets/unsets the token credentials pair to sign requests with.
Sourcepub fn callback(&mut self, callback: impl Into<Option<&'a str>>) -> &mut Self
pub fn callback(&mut self, callback: impl Into<Option<&'a str>>) -> &mut Self
Sets/unsets the oauth_callback URI.
Sourcepub fn verifier(&mut self, verifier: impl Into<Option<&'a str>>) -> &mut Self
pub fn verifier(&mut self, verifier: impl Into<Option<&'a str>>) -> &mut Self
Sets/unsets the oauth_verifier value.
Sourcepub fn nonce(&mut self, nonce: impl Into<Option<&'a str>>) -> &mut Self
pub fn nonce(&mut self, nonce: impl Into<Option<&'a str>>) -> &mut Self
Sets/unsets the oauth_nonce value.
By default, Builder generates a random nonce for each request.
This method overrides that behavior and forces the Builder to use the specified nonce.
This method is for debugging/testing purpose only and should not be used in production.
Sourcepub fn timestamp(
&mut self,
timestamp: impl Into<Option<NonZeroU64>>,
) -> &mut Self
pub fn timestamp( &mut self, timestamp: impl Into<Option<NonZeroU64>>, ) -> &mut Self
Sets/unsets the oauth_timestamp value.
By default, Builder uses the timestamp of the time when authorize-like method is called.
This method overrides that behavior and forces the Builder to use the specified timestamp.
This method is for debugging/testing purpose only and should not be used in production.
Sourcepub fn version(&mut self, version: bool) -> &mut Self
pub fn version(&mut self, version: bool) -> &mut Self
Sets whether to include the oauth_version value in requests.
Sourcepub fn get<U, R>(&self, uri: U, request: &R) -> String
Available on crate feature alloc only.
pub fn get<U, R>(&self, uri: U, request: &R) -> String
alloc only.Authorizes a GET request to uri,
returning an HTTP Authorization header value.
uri must not contain a query part, which would result in a wrong signature.
Sourcepub fn put<U, R>(&self, uri: U, request: &R) -> String
Available on crate feature alloc only.
pub fn put<U, R>(&self, uri: U, request: &R) -> String
alloc only.Authorizes a PUT request to uri,
returning an HTTP Authorization header value.
uri must not contain a query part, which would result in a wrong signature.
Sourcepub fn post<U, R>(&self, uri: U, request: &R) -> String
Available on crate feature alloc only.
pub fn post<U, R>(&self, uri: U, request: &R) -> String
alloc only.Authorizes a POST request to uri,
returning an HTTP Authorization header value.
uri must not contain a query part, which would result in a wrong signature.
Sourcepub fn delete<U, R>(&self, uri: U, request: &R) -> String
Available on crate feature alloc only.
pub fn delete<U, R>(&self, uri: U, request: &R) -> String
alloc only.Authorizes a DELETE request to uri,
returning an HTTP Authorization header value.
uri must not contain a query part, which would result in a wrong signature.
Sourcepub fn options<U, R>(&self, uri: U, request: &R) -> String
Available on crate feature alloc only.
pub fn options<U, R>(&self, uri: U, request: &R) -> String
alloc only.Authorizes a OPTIONS request to uri,
returning an HTTP Authorization header value.
uri must not contain a query part, which would result in a wrong signature.
Sourcepub fn head<U, R>(&self, uri: U, request: &R) -> String
Available on crate feature alloc only.
pub fn head<U, R>(&self, uri: U, request: &R) -> String
alloc only.Authorizes a HEAD request to uri,
returning an HTTP Authorization header value.
uri must not contain a query part, which would result in a wrong signature.
Sourcepub fn connect<U, R>(&self, uri: U, request: &R) -> String
Available on crate feature alloc only.
pub fn connect<U, R>(&self, uri: U, request: &R) -> String
alloc only.Authorizes a CONNECT request to uri,
returning an HTTP Authorization header value.
uri must not contain a query part, which would result in a wrong signature.
Sourcepub fn patch<U, R>(&self, uri: U, request: &R) -> String
Available on crate feature alloc only.
pub fn patch<U, R>(&self, uri: U, request: &R) -> String
alloc only.Authorizes a PATCH request to uri,
returning an HTTP Authorization header value.
uri must not contain a query part, which would result in a wrong signature.
Sourcepub fn trace<U, R>(&self, uri: U, request: &R) -> String
Available on crate feature alloc only.
pub fn trace<U, R>(&self, uri: U, request: &R) -> String
alloc only.Authorizes a TRACE request to uri,
returning an HTTP Authorization header value.
uri must not contain a query part, which would result in a wrong signature.
Sourcepub fn put_form<U, R>(&self, uri: U, request: &R) -> String
Available on crate feature alloc only.
pub fn put_form<U, R>(&self, uri: U, request: &R) -> String
alloc only.Authorizes a PUT request to uri,
writing the OAuth protocol parameters to an x-www-form-urlencoded string
along with the other request parameters.
uri must not contain a query part, which would result in a wrong signature.
Sourcepub fn post_form<U, R>(&self, uri: U, request: &R) -> String
Available on crate feature alloc only.
pub fn post_form<U, R>(&self, uri: U, request: &R) -> String
alloc only.Authorizes a POST request to uri,
writing the OAuth protocol parameters to an x-www-form-urlencoded string
along with the other request parameters.
uri must not contain a query part, which would result in a wrong signature.
Sourcepub fn options_form<U, R>(&self, uri: U, request: &R) -> String
Available on crate feature alloc only.
pub fn options_form<U, R>(&self, uri: U, request: &R) -> String
alloc only.Authorizes a OPTIONS request to uri,
writing the OAuth protocol parameters to an x-www-form-urlencoded string
along with the other request parameters.
uri must not contain a query part, which would result in a wrong signature.
Sourcepub fn patch_form<U, R>(&self, uri: U, request: &R) -> String
Available on crate feature alloc only.
pub fn patch_form<U, R>(&self, uri: U, request: &R) -> String
alloc only.Authorizes a PATCH request to uri,
writing the OAuth protocol parameters to an x-www-form-urlencoded string
along with the other request parameters.
uri must not contain a query part, which would result in a wrong signature.
Sourcepub fn get_query<W, R>(&self, uri: W, request: &R) -> W
pub fn get_query<W, R>(&self, uri: W, request: &R) -> W
Authorizes a GET request to uri, appending
the OAuth protocol parameters to uri along with the other request parameters.
uri must not contain a query part, which would result in a wrong signature.
Sourcepub fn put_query<W, R>(&self, uri: W, request: &R) -> W
pub fn put_query<W, R>(&self, uri: W, request: &R) -> W
Authorizes a PUT request to uri, appending
the OAuth protocol parameters to uri along with the other request parameters.
uri must not contain a query part, which would result in a wrong signature.
Sourcepub fn post_query<W, R>(&self, uri: W, request: &R) -> W
pub fn post_query<W, R>(&self, uri: W, request: &R) -> W
Authorizes a POST request to uri, appending
the OAuth protocol parameters to uri along with the other request parameters.
uri must not contain a query part, which would result in a wrong signature.
Sourcepub fn delete_query<W, R>(&self, uri: W, request: &R) -> W
pub fn delete_query<W, R>(&self, uri: W, request: &R) -> W
Authorizes a DELETE request to uri, appending
the OAuth protocol parameters to uri along with the other request parameters.
uri must not contain a query part, which would result in a wrong signature.
Sourcepub fn options_query<W, R>(&self, uri: W, request: &R) -> W
pub fn options_query<W, R>(&self, uri: W, request: &R) -> W
Authorizes a OPTIONS request to uri, appending
the OAuth protocol parameters to uri along with the other request parameters.
uri must not contain a query part, which would result in a wrong signature.
Sourcepub fn head_query<W, R>(&self, uri: W, request: &R) -> W
pub fn head_query<W, R>(&self, uri: W, request: &R) -> W
Authorizes a HEAD request to uri, appending
the OAuth protocol parameters to uri along with the other request parameters.
uri must not contain a query part, which would result in a wrong signature.
Sourcepub fn connect_query<W, R>(&self, uri: W, request: &R) -> W
pub fn connect_query<W, R>(&self, uri: W, request: &R) -> W
Authorizes a CONNECT request to uri, appending
the OAuth protocol parameters to uri along with the other request parameters.
uri must not contain a query part, which would result in a wrong signature.
Sourcepub fn patch_query<W, R>(&self, uri: W, request: &R) -> W
pub fn patch_query<W, R>(&self, uri: W, request: &R) -> W
Authorizes a PATCH request to uri, appending
the OAuth protocol parameters to uri along with the other request parameters.
uri must not contain a query part, which would result in a wrong signature.
Sourcepub fn trace_query<W, R>(&self, uri: W, request: &R) -> W
pub fn trace_query<W, R>(&self, uri: W, request: &R) -> W
Authorizes a TRACE request to uri, appending
the OAuth protocol parameters to uri along with the other request parameters.
uri must not contain a query part, which would result in a wrong signature.
Available on crate feature alloc only.
alloc only.Authorizes a request to uri with a custom HTTP request method,
returning an HTTP Authorization header value.
uri must not contain a query part, which would result in a wrong signature.
Sourcepub fn to_form<U, R>(&self, method: &str, uri: U, request: &R) -> String
Available on crate feature alloc only.
pub fn to_form<U, R>(&self, method: &str, uri: U, request: &R) -> String
alloc only.Authorizes a request to uri with a custom HTTP request method, writing the OAuth protocol
parameters to an x-www-form-urlencoded string along with the other request parameters.
uri must not contain a query part, which would result in a wrong signature.
Sourcepub fn to_query<W, R>(&self, method: &str, uri: W, request: &R) -> W
pub fn to_query<W, R>(&self, method: &str, uri: W, request: &R) -> W
Authorizes a request to uri with a custom HTTP request method, appending the OAuth
protocol parameters to uri along with the other request parameters.
uri must not contain a query part, which would result in a wrong signature.
Same as authorize except that this writes the resulting Authorization header value
into buf.
Sourcepub fn to_form_with_buf<W, U, R>(
&self,
buf: W,
method: &str,
uri: U,
request: &R,
) -> W
Available on crate feature alloc only.
pub fn to_form_with_buf<W, U, R>( &self, buf: W, method: &str, uri: U, request: &R, ) -> W
alloc only.Same as to_form except that this writes the resulting x-www-form-urlencoded string
into buf.
Available on crate feature alloc only.
alloc only.Authorizes a request and consumes self, returning an HTTP Authorization header value.
Unlike authorize, this does not clone the signature method and may be more efficient for
non-Copy signature methods like RsaSha1.
For HmacSha1, &RsaSha1 and Plaintext, cloning is no-op or very cheap so you should
use authorize instead.
Sourcepub fn into_form<U, R>(self, method: &str, uri: U, request: &R) -> String
Available on crate feature alloc only.
pub fn into_form<U, R>(self, method: &str, uri: U, request: &R) -> String
alloc only.Authorizes a request and consumes self, writing the OAuth protocol parameters to
an x-www-form-urlencoded string along with the other request parameters.
Unlike to_form, this does not clone the signature method and may be more efficient for
non-Copy signature methods like RsaSha1.
For HmacSha1, &RsaSha1 and Plaintext, cloning is no-op or very cheap so you should
use to_form instead.
Sourcepub fn into_query<W, R>(self, method: &str, uri: W, request: &R) -> W
pub fn into_query<W, R>(self, method: &str, uri: W, request: &R) -> W
Authorizes a request and consumes self, appending the OAuth protocol parameters to
uri along with the other request parameters.
Unlike to_query, this does not clone the signature method and may be more efficient for
non-Copy signature methods like RsaSha1.
For HmacSha1, &RsaSha1 and Plaintext, cloning is no-op or very cheap so you should
use to_query instead.
Same as into_authorization except that this writes the resulting Authorization header
value into buf.