Crate oauth1_client

Source
Expand description

§OAuth1.0a Client Library

§Overview

This library handles OAuth1.0a in a network-backend agnostic way.
The current intended usage is that you implement your own code to send an OAuthRequest with whichever networking library you chose.

It handles all the difficult parts of the process, letting you focus on just sending your data.

use http::Uri;
use oauth1_client::*;

let consumer = ConsumerCredentials::new(
    "example_consumer_key",
    "example_consumer_secret"
);

let token = AccessToken::new(
    "example_token",
    "example_token_secret"
);

let request = OAuthRequest::builder(
    Uri::from_static("https://example.com/api"),
    AuthenticationLevel::Token(consumer, token),
    Box::new(HmacSha1Signature)
)
.scheme(AuthorizationScheme::Header)
.add_auth_parameters(&[Parameter::new("realm", "http://sp.example.com/")])
.add_parameters(&[
    Parameter::new("message", "Hello World!"),
    Parameter::new("extra", "meow"),
])
.build()
.unwrap();

// Now you can send the request

§Basic Abstractions

§Authentication Levels

There are two AuthenticationLevels a request can have:

§Signature Methods

§Authorization Schemes

The AuthorizationScheme decides how to structure the request. The default is AuthorizationScheme::Header as it is recommended by the standard. See its documentation page for more details.

§Authentication Flow

See the module-level documentation for flow.

Re-exports§

pub use signature::*;

Modules§

flow
Token Acquisition Flow Module
percent_encoding
Module with methods for handling RFC3986 percent encoding with an OAuth1.0a specific reserved characters set
signature
This module contains all the SignatureMethods specified by the standard.

Structs§

AccessToken
A token and token secret, required for authorized requests
ConsumerCredentials
Consumer key and secret, required for all OAuth requests
OAuthRequest
A ready-to-send request
OAuthRequestBuilder
A builder for OAuthRequest
Parameter
OAuth protocol parameter - case-sensitive name + value

Enums§

AuthenticationLevel
Whether this request is authorized or not
AuthorizationScheme
How exactly should the request be made
OAuthError
Error types specific to this crate