[−][src]Struct modio::auth::Auth
Authentication Flow interface to retrieve access tokens. See the mod.io Authentication docs for more information.
Example
use std::io::{self, Write}; use modio::{Credentials, Modio, Result}; fn prompt(prompt: &str) -> io::Result<String> { print!("{}", prompt); io::stdout().flush()?; let mut buffer = String::new(); io::stdin().read_line(&mut buffer)?; Ok(buffer.trim().to_string()) } #[tokio::main] async fn main() -> Result<()> { let modio = Modio::new(Credentials::new("api-key"))?; let email = prompt("Enter email: ").expect("read email"); modio.auth().request_code(&email).await?; let code = prompt("Enter security code: ").expect("read code"); let token = modio.auth().security_code(&code).await?; // Consume the endpoint and create an endpoint with new credentials. let _modio = modio.with_credentials(token); Ok(()) }
Implementations
impl Auth
[src]
pub async fn request_code(self, email: &str) -> Result<()>
[src]
Request a security code be sent to the email of the user. [required: apikey]
pub async fn security_code(self, code: &str) -> Result<Credentials>
[src]
Get the access token for a security code. [required: apikey]
pub async fn external<T>(self, auth_options: T) -> Result<Credentials> where
T: Into<AuthOptions>,
[src]
T: Into<AuthOptions>,
Authenticate via external services (Steam, GOG, itch.io, Switch, Xbox, Discord, Oculus).
See the mod.io docs for more information.
Examples
use modio::auth::SteamOptions; let opts = SteamOptions::new("ticket"); modio.auth().external(opts).await?; use modio::auth::GalaxyOptions; let opts = GalaxyOptions::new("ticket").email("foobar@example.com"); modio.auth().external(opts).await?; use modio::auth::ItchioOptions; let opts = ItchioOptions::new("token").expired_at(now + two_weeks); modio.auth().external(opts).await?;
pub async fn link(self, options: LinkOptions) -> Result<()>
[src]
Link an external account. Requires an auth token from the external platform.
See the mod.io docs for more information.
Auto Trait Implementations
impl !RefUnwindSafe for Auth
[src]
impl Send for Auth
[src]
impl Sync for Auth
[src]
impl Unpin for Auth
[src]
impl !UnwindSafe for Auth
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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.
pub 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>,