pub struct OAuthParameters<'a, TSM>where
    TSM: SignatureMethod + Clone,{ /* private fields */ }
Expand description

Represents OAuth parameters including oauth_nonce, oauth_timestamp, realm, and others.

Basic usage

use reqwest_oauth1::OAuthClientProvider;

let consumer_key = "[CONSUMER_KEY]";
let consumer_secret = "[CONSUMER_SECRET]";
let secrets = reqwest_oauth1::Secrets::new(consumer_key, consumer_secret);

let nonce = "[NONCE]";
let timestamp = 100_000_001u64;
let callback = "http://example.com/ready";

let params = reqwest_oauth1::OAuthParameters::new()
    .nonce(nonce)
    .timestamp(timestamp)
    .callback(callback);

let req = reqwest::Client::new()
    .oauth1_with_params(secrets, params)
    .post("http://example.com/")
    // and so on...
    ;

Note

You can specify same parameters as get/post queries and they will superseded with the specified one in the OAuthParameters.

use reqwest_oauth1::OAuthClientProvider;

let consumer_key = "[CONSUMER_KEY]";
let consumer_secret = "[CONSUMER_SECRET]";
let secrets = reqwest_oauth1::Secrets::new(consumer_key, consumer_secret);

let params = reqwest_oauth1::OAuthParameters::new()
    .nonce("ThisNonceWillBeSuperseded");
let req = reqwest::Client::new()
    .oauth1_with_params(secrets, params)
    .get("http://example.com/")
    .query(&[("nonce", "ThisNonceWillSupersedeTheOldOne")])
    // and so on...
    ;

Implementations§

source§

impl OAuthParameters<'_, HmacSha1>

source

pub fn new() -> Self

source§

impl<'a, TSM> OAuthParameters<'a, TSM>where TSM: SignatureMethod + Clone,

source

pub fn callback<T>(self, callback: T) -> Selfwhere T: Into<Cow<'a, str>>,

set the oauth_callback value

source

pub fn nonce<T>(self, nonce: T) -> Selfwhere T: Into<Cow<'a, str>>,

set the oauth_nonce value

source

pub fn realm<T>(self, realm: T) -> Selfwhere T: Into<Cow<'a, str>>,

set the realm value

Note

this parameter will not be included in the signature-base string. cf. https://tools.ietf.org/html/rfc5849#section-3.4.1.3.1

source

pub fn timestamp<T>(self, timestamp: T) -> Selfwhere T: Into<u64>,

set the oauth_timestamp value

source

pub fn verifier<T>(self, verifier: T) -> Selfwhere T: Into<Cow<'a, str>>,

set the oauth_verifier value

source

pub fn version<T>(self, version: T) -> Selfwhere T: Into<bool>,

set the oauth_version value (boolean)

Note

When the version has value true, oauth_version will be set with “1.0”. Otherwise, oauth_version will not be included in your request. In oauth1, oauth_version value must be “1.0” or not specified.

source

pub fn signature_method<T>(self, signature_method: T) -> OAuthParameters<'a, T>where T: SignatureMethod + Clone,

Trait Implementations§

source§

impl<'a, TSM> Clone for OAuthParameters<'a, TSM>where TSM: SignatureMethod + Clone + Clone,

source§

fn clone(&self) -> OAuthParameters<'a, TSM>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'a, TSM> Debug for OAuthParameters<'a, TSM>where TSM: SignatureMethod + Clone + Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for OAuthParameters<'static, HmacSha1>

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a, TSM> RefUnwindSafe for OAuthParameters<'a, TSM>where TSM: RefUnwindSafe,

§

impl<'a, TSM> Send for OAuthParameters<'a, TSM>where TSM: Send,

§

impl<'a, TSM> Sync for OAuthParameters<'a, TSM>where TSM: Sync,

§

impl<'a, TSM> Unpin for OAuthParameters<'a, TSM>where TSM: Unpin,

§

impl<'a, TSM> UnwindSafe for OAuthParameters<'a, TSM>where TSM: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more