Enum orca::net::auth::OAuth[][src]

pub enum OAuth {
    Script {
        id: String,
        secret: String,
        username: String,
        password: String,
        token: String,
    },
    InstalledApp {
        id: String,
        redirect: String,
        token: RefCell<String>,
        refresh_token: RefCell<Option<String>>,
        expire_instant: Cell<Option<Instant>>,
    },
}

Enum representing OAuth information that has been aquired from authorization. This should only be used internally within orca.

Variants

Script app type

Fields of Script

Id of the script

Secret of the script

Username of the script user

Password of the script user

Token retrieved from script authorization

Installed app type

Fields of InstalledApp

Id of the installed app

Redirect url of the installed app

Token currently in use

The refresh token (to be used to retrieve a new token once the current one expires). Not present if temporary authorization was requested

Instant when the current token expires

Methods

impl OAuth
[src]

Refreshes the token (only necessary for installed app types)

Authorize the app as a script

Arguments

  • conn - A refernce to the connection to authorize
  • id - The app id registered on Reddit
  • secret - The app secret registered on Reddit
  • username - The username of the user to authorize as
  • password - The password of the user to authorize as

Authorize the app as an installed app

Arguments

  • conn - A reference to the connection to authorize
  • id - The app id registered on Reddit
  • redirect - The app redirect URI registered on Reddit
  • response_gen - An optional function that generates a hyper Response to give to the user based on the result of the authorization attempt. The signature is (Result<String, InstalledAppError) -> Result<Response, Response>. The result passed in is either Ok with the code recieved, or Err with the error that occurred. The value returned should usually be an Ok(Response), but you can return Err(Response) to indicate that an error occurred within the function.
  • scopes - A reference to a Scopes instance representing the capabilites you are requesting as an installed app.

Trait Implementations

impl Debug for OAuth
[src]

Formats the value using the given formatter. Read more

impl Clone for OAuth
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Auto Trait Implementations

impl Send for OAuth

impl !Sync for OAuth