Struct oauth2::Config
[−]
[src]
pub struct Config { /* fields omitted */ }
Stores the configuration for an OAuth2 client.
Methods
impl Config
[src]
fn new<I, S, A, T>(
client_id: I,
client_secret: S,
auth_url: A,
token_url: T
) -> Self where
I: Into<String>,
S: Into<String>,
A: AsRef<str>,
T: AsRef<str>,
client_id: I,
client_secret: S,
auth_url: A,
token_url: T
) -> Self where
I: Into<String>,
S: Into<String>,
A: AsRef<str>,
T: AsRef<str>,
Initializes the OAuth2 client with the client ID, client secret, the base authorization URL and the URL ment for requesting the access token.
fn add_scope<S>(self, scope: S) -> Self where
S: Into<String>,
S: Into<String>,
Appends a new scope to the authorization URL.
fn set_response_type<R>(self, response_type: R) -> Self where
R: Into<ResponseType>,
R: Into<ResponseType>,
Allows setting a particular response type. Both &str
and ResponseType
work here.
The default response type is code.
fn set_redirect_url<R>(self, redirect_url: R) -> Self where
R: Into<String>,
R: Into<String>,
Allows setting the redirect URL.
fn set_state<S>(self, state: S) -> Self where
S: Into<String>,
S: Into<String>,
Allows setting a state parameter inside the authorization URL, which we'll be returned by the server after the authorization is over.
Produces the full authorization URL.
fn exchange<C>(&self, code: C) -> Result<Token, TokenError> where
C: Into<String>,
C: Into<String>,
: please use exchange_code
instead
Exchanges a code produced by a successful authorization process with an access token.
fn exchange_code<C>(&self, code: C) -> Result<Token, TokenError> where
C: Into<String>,
C: Into<String>,
Exchanges a code produced by a successful authorization process with an access token.
fn exchange_client_credentials(&self) -> Result<Token, TokenError>
Requests an access token for the client credentials grant type.
fn exchange_password<U, P>(
&self,
username: U,
password: P
) -> Result<Token, TokenError> where
U: Into<String>,
P: Into<String>,
&self,
username: U,
password: P
) -> Result<Token, TokenError> where
U: Into<String>,
P: Into<String>,
Requests an access token for the password grant type.