1 unstable release

0.1.0 Oct 2, 2020

#21 in #authorization

MIT license

13KB
144 lines

ezoauth

An easy to use OAuth2 client for rust

The crate automatically starts a webserver in a background thread and makes the authorization flow a simple matter of calling ezoauth::authenticate with your OAuthConfig.

Example Usage

let config = ezoauth::OAuthConfig {
    auth_url: "https://discord.com/api/oauth2/authorize",
    token_url: "https://discord.com/api/oauth2/token",
    redirect_url: "http://localhost:8000",
    client_id: "...",
    client_secret: "...",
    scopes: vec!["identify"],
};
let (rx, auth_url) = ezoauth::authenticate(config, "localhost:8000")?;

println!("Browse to {}", auth_url);

let token = rx.recv().unwrap()?;

LICENSE

MIT © Jakob Hellermann


lib.rs:

An easy to use OAuth2 client flow library based on oauth2-rs.

# fn main() -> Result<(), ezoauth::Error> {
let config = ezoauth::OAuthConfig {
    auth_url: "https://discord.com/api/oauth2/authorize",
    token_url: "https://discord.com/api/oauth2/token",
    redirect_url: "http://localhost:8000",
    client_id: "...",
    client_secret: "...",
    scopes: vec!["identify"],
};
let (rx, auth_url) = ezoauth::authenticate(config, "localhost:8000")?;

println!("Browse to {}", auth_url);

let token = rx.recv().unwrap()?;
# Ok(())
# }

Dependencies

~5–9.5MB
~215K SLoC