oauth10a

Crates.iooauth10a
lib.rsoauth10a
version1.5.1
sourcesrc
created_at2021-10-12 16:27:09.421953
updated_at2023-07-31 16:18:23.428836
descriptionA rust implementation of the oauth 1.0a protocol fully-async with logging, metrics and tracing facilities
homepage
repositoryhttps://github.com/CleverCloud/oauth10a-rust
max_upload_size
id464043
size52,662
Florentin DUBOIS (FlorentinDUBOIS)

documentation

README

OAuth 1.0a crate

This crate provides an oauth 1.0a client implementation fully-async with logging, metrics and tracing facilities. It was firstly designed to interact with the Clever-Cloud's api, but has been extended to be more generic.

Status

This crate is ready for production, if you may have bugs, so please an issue to fix the trouble.

Installation

To install this dependency, just add the following line to your Cargo.toml manifest.

oauth10a = { version = "^1.5.1", features = ["metrics"] }

Usage

Below, you will find an example of executing a simple request to an api.

use std::error::Error;

use oauth10a::client::{Client, Credentials, RestClient, proxy::ProxyConnectorBuilder};

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
    let connector = ProxyConnectorBuilder::try_from_env()?;
    let client = Client::builder()
        .with_credentials(Credentials {
            token: "".to_string(),
            secret: "".to_string(),
            consumer_key: "".to_string(),
            consumer_secret: "".to_string(),
        })
        .build(connector);

    let _obj: BtreeMap<String, String> = client.get("https://example.com/object.json").await?;

    Ok(())
}

Features

name description
default Default enable features are client, logging, proxy
client The oauth 1.0a client implementation
logging Use the log facility crate to print logs
metrics Use once_cell and prometheus crates to register metrics
proxy Enable the support of environment variable http_proxy and https_proxy

Metrics

Below, the exposed metrics gathered by prometheus:

name labels kind description
oauth10a_client_request endpoint: String, method: String, status: Integer Counter number of request on api
oauth10a_client_request_duration endpoint: String, method: String, status: Integer, unit: String Counter duration of request on api

License

See the license.

Getting in touch

Commit count: 114

cargo fmt