[][src]Struct rocket_oauth2::OAuthConfig

pub struct OAuthConfig { /* fields omitted */ }

Holds configuration for an OAuth application. This consists of the Provider details, a client_id and client_secret, and an optional redirect_uri.

Implementations

impl OAuthConfig[src]

pub fn new(
    provider: impl Provider,
    client_id: String,
    client_secret: String,
    redirect_uri: Option<String>
) -> OAuthConfig
[src]

Construct an OAuthConfig specifying all parameters manually.

Example

use rocket_oauth2::{OAuthConfig, StaticProvider};

let provider = StaticProvider::GitHub;
let client_id = "...".to_string();
let client_secret = "...".to_string();
let redirect_uri = Some("http://localhost:8000/auth/github".to_string());

let config = OAuthConfig::new(provider, client_id, client_secret, redirect_uri);

pub fn from_config(config: &Config, name: &str) -> Result<OAuthConfig>[src]

Construct an OAuthConfig from Rocket configuration.

Example

Rocket.toml

[global.oauth.github]
provider = "GitHub"
client_id = "..."
client_secret = "..."
redirect_uri = "http://localhost:8000/auth/github"

main.rs

use rocket::fairing::AdHoc;
use rocket_oauth2::{HyperSyncRustlsAdapter, OAuth2, OAuthConfig};

struct GitHub;

fn main() {
    rocket::ignite()
        .attach(AdHoc::on_attach("OAuth Config", |rocket| {
            let config = OAuthConfig::from_config(rocket.config(), "github").unwrap();
            Ok(rocket.attach(OAuth2::<GitHub>::custom(HyperSyncRustlsAdapter::default(), config)))
        }))
        .launch();
}

pub fn provider(&self) -> &dyn Provider[src]

Get the Provider for this configuration.

pub fn client_id(&self) -> &str[src]

Get the client id for this configuration.

pub fn client_secret(&self) -> &str[src]

Get the client secret for this configuration.

pub fn redirect_uri(&self) -> Option<&str>[src]

Get the redirect URI for this configuration.

Trait Implementations

impl Debug for OAuthConfig[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T, I> AsResult<T, I> for T where
    I: Input, 

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> IntoCollection<T> for T

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Typeable for T where
    T: Any

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