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
Script app type
Fields of Script
id: String | Id of the script |
secret: String | Secret of the script |
username: String | Username of the script user |
password: String | Password of the script user |
token: String | Token retrieved from script authorization |
InstalledApp
Installed app type
Fields of InstalledApp
id: String | Id of the installed app |
redirect: String | Redirect url of the installed app |
token: RefCell<String> | Token currently in use |
refresh_token: RefCell<Option<String>> | The refresh token (to be used to retrieve a new token once the current one expires). Not present if temporary authorization was requested |
expire_instant: Cell<Option<Instant>> | Instant when the current token expires |
Methods
impl OAuth
[src]
impl OAuth
pub fn refresh(&self, conn: &Connection) -> Result<(), Error>
[src]
pub fn refresh(&self, conn: &Connection) -> Result<(), Error>
Refreshes the token (only necessary for installed app types)
pub fn create_script(
conn: &Connection,
id: &str,
secret: &str,
username: &str,
password: &str
) -> Result<OAuth, Error>
[src]
pub fn create_script(
conn: &Connection,
id: &str,
secret: &str,
username: &str,
password: &str
) -> Result<OAuth, Error>
Authorize the app as a script
Arguments
conn
- A refernce to the connection to authorizeid
- The app id registered on Redditsecret
- The app secret registered on Redditusername
- The username of the user to authorize aspassword
- The password of the user to authorize as
pub fn create_installed_app<I: Into<Option<Arc<ResponseGenFn>>>>(
conn: &Connection,
id: &str,
redirect: &str,
response_gen: I,
scopes: &Scopes
) -> Result<OAuth, Error>
[src]
pub fn create_installed_app<I: Into<Option<Arc<ResponseGenFn>>>>(
conn: &Connection,
id: &str,
redirect: &str,
response_gen: I,
scopes: &Scopes
) -> Result<OAuth, Error>
Authorize the app as an installed app
Arguments
conn
- A reference to the connection to authorizeid
- The app id registered on Redditredirect
- The app redirect URI registered on Redditresponse_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]
impl Debug for OAuth
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Clone for OAuth
[src]
impl Clone for OAuth