pub struct RedditOAuth {
pub callback_url: String,
pub oauth_state: OAuthState,
pub error_string: Option<String>,
pub state_string: String,
pub client_credentials: RedditClientCredentials,
}Fields§
§callback_url: String§oauth_state: OAuthState§error_string: Option<String>§state_string: String§client_credentials: RedditClientCredentialsImplementations§
Source§impl RedditOAuth
impl RedditOAuth
pub fn default() -> RedditOAuth
Sourcepub fn state_string(self, state_string: &str) -> RedditOAuth
pub fn state_string(self, state_string: &str) -> RedditOAuth
Set state_string
Sourcepub fn oauth_state(self, oauth_state: OAuthState) -> RedditOAuth
pub fn oauth_state(self, oauth_state: OAuthState) -> RedditOAuth
Set oauth_state
Sourcepub fn error_state(self, error_state: &str) -> RedditOAuth
pub fn error_state(self, error_state: &str) -> RedditOAuth
Set `error_string’
Sourcepub fn build(self) -> RedditOAuth
pub fn build(self) -> RedditOAuth
Validate RedditOAuth object. After calling, object is ready to use
Authorize user by opening default browser and present reddit authorization dialog. This needs user interaction to receive Bearer Token
§Arguments
scope- String of concatenated scopes the bearer token should have authorization ofduration- AuthorizationTime::permanent or AuthorizationTime::temporary
§Returns
Option<OAuthToken> If authorization was successfull, OAuthToken is set, otherwise RedditOAuth.oauth_state=OAuthState::error with an error message in RedditOAuth.error_string
If duration is permanent, bearer token will be invalid after one hour. The token has to be refreshed with the refresh_token
Sourcepub fn refresh_token(&mut self, to_refresh: &OAuthToken) -> Option<OAuthToken>
pub fn refresh_token(&mut self, to_refresh: &OAuthToken) -> Option<OAuthToken>
Refresh bearer token when the previous one expired
§Arguments
to_refresh- Old bearer token which should be refreshed
§Returns
Option<OAuthToken> If authorization was successfull, OAuthToken is set, otherwise RedditOAuth.oauth_state=OAuthState::error with an error message in RedditOAuth.error_string
If duration is permanent, bearer token will be invalid after one hour. The token has to be refreshed with the refresh_token
Sourcepub fn revoke_token(&mut self, to_revoke: &OAuthToken) -> Result<(), String>
pub fn revoke_token(&mut self, to_revoke: &OAuthToken) -> Result<(), String>
Sourcepub fn get_initial_access_token(&self, state: &str) -> Option<OAuthToken>
pub fn get_initial_access_token(&self, state: &str) -> Option<OAuthToken>
Request access token
§Arguments
state- State string returned by reddit authorization process
§Returns
Option<OAuthToken> If authorization was successfull, OAuthToken is set, otherwise RedditOAuth.oauth_state=OAuthState::error with an error message in RedditOAuth.error_string
If duration is permanent, bearer token will be invalid after one hour. The token has to be refreshed with the refresh_token
Trait Implementations§
Source§impl Clone for RedditOAuth
impl Clone for RedditOAuth
Source§fn clone(&self) -> RedditOAuth
fn clone(&self) -> RedditOAuth
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more