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:
- AuthenticationLevel::Consumer - contains only ConsumerCredentials - you’re identifying as a specific application, but acting on your own behalf
- AuthenticationLevel::Token - contains ConsumerCredentials and an AccessToken - you’re identifying as a specific application and specific user, and acting on behalf of that user
§Signature Methods
- signature::HmacSha1Signature - A basic signature created using the consumer secret and token secret.
- signature::PlaintextSignature - Insecure. Instead of a signature, sends the consumer and token secrets in plaintext.
- signature::RsaSha1Signature - Signs the request with an RSA private key. Requires the
rsa
crate feature to be enabled.
§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§
- Access
Token - A token and token secret, required for authorized requests
- Consumer
Credentials - Consumer key and secret, required for all OAuth requests
- OAuth
Request - A ready-to-send request
- OAuth
Request Builder - A builder for OAuthRequest
- Parameter
- OAuth protocol parameter - case-sensitive name + value
Enums§
- Authentication
Level - Whether this request is authorized or not
- Authorization
Scheme - How exactly should the request be made
- OAuth
Error - Error types specific to this crate