[−][src]Struct rocket_oauth2::OAuthConfig
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]
provider: impl Provider,
client_id: String,
client_secret: String,
redirect_uri: Option<String>
) -> OAuthConfig
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
Auto Trait Implementations
impl !RefUnwindSafe for OAuthConfig
impl Send for OAuthConfig
impl Sync for OAuthConfig
impl Unpin for OAuthConfig
impl !UnwindSafe for OAuthConfig
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T, I> AsResult<T, I> for T where
I: Input,
I: Input,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> IntoCollection<T> for T
fn into_collection<A>(self) -> SmallVec<A> where
A: Array<Item = T>,
A: Array<Item = T>,
fn mapped<U, F, A>(self, f: F) -> SmallVec<A> where
A: Array<Item = U>,
F: FnMut(T) -> U,
A: Array<Item = U>,
F: FnMut(T) -> U,
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]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Typeable for T where
T: Any,
T: Any,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,