[−][src]Struct oauth2::Client
Stores the configuration for an OAuth2 client.
Methods
impl Client
[src]
pub fn new(client_id: impl AsRef<str>, auth_url: Url, token_url: Url) -> Self
[src]
Initializes an OAuth2 client with the fields common to most OAuth2 flows.
Arguments
client_id
- Client IDauth_url
- Authorization endpoint: used by the client to obtain authorization from the resource owner via user-agent redirection. This URL is used in all standard OAuth2 flows except the Resource Owner Password Credentials Grant and the Client Credentials Grant.token_url
- Token endpoint: used by the client to exchange an authorization grant (code) for an access token, typically with client authentication. This URL is used in all standard OAuth2 flows except the Implicit Grant. If this value is set toNone
, theexchange_*
methods will returnErr(RequestTokenError::Other(_))
.
pub fn set_client_secret(&mut self, client_secret: impl Into<ClientSecret>)
[src]
Configure the client secret to use.
pub fn add_scope(&mut self, scope: impl Into<Scope>)
[src]
Appends a new scope to the authorization URL.
pub fn set_auth_type(&mut self, auth_type: AuthType)
[src]
Configures the type of client authentication used for communicating with the authorization server.
The default is to use HTTP Basic authentication, as recommended in Section 2.3.1 of RFC 6749.
pub fn set_redirect_url(&mut self, redirect_url: Url)
[src]
Sets the the redirect URL used by the authorization endpoint.
pub fn authorize_url(&self, state: &State) -> Url
[src]
Produces the full authorization URL used by the Authorization Code Grant flow, which is the most common OAuth2 flow.
Arguments
state
- A state value to include in the request. The authorization server includes this value when redirecting the user-agent back to the client.
Security Warning
Callers should use a fresh, unpredictable state
for each authorization
request and verify that this value matches the state
parameter passed
by the authorization server to the redirect URI. Doing so mitigates
Cross-Site Request Forgery
attacks.
pub fn authorize_url_implicit(&self, state: &State) -> Url
[src]
Produces the full authorization URL used by the Implicit Grant flow.
Arguments
state
- A state value to include in the request. The authorization server includes this value when redirecting the user-agent back to the client.
Security Warning
Callers should use a fresh, unpredictable state
for each authorization request and verify
that this value matches the state
parameter passed by the authorization server to the
redirect URI. Doing so mitigates
Cross-Site Request Forgery
attacks.
pub fn exchange_code(&self, code: impl Into<AuthorizationCode>) -> Request
[src]
Exchanges a code produced by a successful authorization process with an access token.
Acquires ownership of the code
because authorization codes may only be used to retrieve
an access token from the authorization server.
See https://tools.ietf.org/html/rfc6749#section-4.1.3
pub fn exchange_password<'a>(
&'a self,
username: impl AsRef<str>,
password: impl AsRef<str>
) -> Request<'a>
[src]
&'a self,
username: impl AsRef<str>,
password: impl AsRef<str>
) -> Request<'a>
Requests an access token for the password grant type.
See https://tools.ietf.org/html/rfc6749#section-4.3.2
pub fn exchange_client_credentials(&self) -> Request
[src]
Requests an access token for the client credentials grant type.
See https://tools.ietf.org/html/rfc6749#section-4.4.2
pub fn exchange_refresh_token(&self, refresh_token: &RefreshToken) -> Request
[src]
Exchanges a refresh token for an access token
See https://tools.ietf.org/html/rfc6749#section-6
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl UnwindSafe for Client
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,