Trait rawr::auth::Authenticator
[−]
[src]
pub trait Authenticator { fn login(&mut self, client: &Client, user_agent: &str) -> Result<(), APIError>; fn logout(&mut self, client: &Client, user_agent: &str) -> Result<(), APIError>; fn scopes(&self) -> Vec<String>; fn headers(&self) -> Headers; fn oauth(&self) -> bool; fn refresh_token(&mut self, client: &Client, user_agent: &str) -> Result<(), APIError> { ... } }
Trait for any method of authenticating with the Reddit API.
Required Methods
fn login(&mut self, client: &Client, user_agent: &str) -> Result<(), APIError>
Logs in and fetches relevant tokens.
fn logout(&mut self, client: &Client, user_agent: &str) -> Result<(), APIError>
Logs out and invalidates tokens if applicable.
fn scopes(&self) -> Vec<String>
A list of OAuth scopes that this Authenticator
can access. Currently, the result of this
is not used, but the correct scopes should be returned. If all scopes can be accessed,
this is signified by a vec!["*"]. If it is read-only, the result is vec!["read"].
fn headers(&self) -> Headers
Returns the headers needed to authenticate. Must be done after login()
.
fn oauth(&self) -> bool
true
if this authentication method requires the OAuth API.
Provided Methods
fn refresh_token(&mut self, client: &Client, user_agent: &str) -> Result<(), APIError>
Called if a token expiration error occurs.
Implementors
impl Authenticator for AnonymousAuthenticator
impl Authenticator for PasswordAuthenticator