[−][src]Struct oauth2::Client
Stores the configuration for an OAuth2 client.
Methods
impl<TE, TR, TT> Client<TE, TR, TT> where
TE: ErrorResponseType,
TR: TokenResponse<TT>,
TT: TokenType,
[src]
TE: ErrorResponseType,
TR: TokenResponse<TT>,
TT: TokenType,
pub fn new(
client_id: ClientId,
client_secret: Option<ClientSecret>,
auth_url: AuthUrl,
token_url: Option<TokenUrl>
) -> Self
[src]
client_id: ClientId,
client_secret: Option<ClientSecret>,
auth_url: AuthUrl,
token_url: Option<TokenUrl>
) -> Self
Initializes an OAuth2 client with the fields common to most OAuth2 flows.
Arguments
client_id
- Client IDclient_secret
- Optional client secret. A client secret is generally used for private (server-side) OAuth2 clients and omitted from public (client-side or native app) OAuth2 clients (see RFC 8252).auth_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 add_scope(self, scope: Scope) -> Self
[src]
Appends a new scope to the authorization URL.
pub fn set_auth_type(self, auth_type: AuthType) -> Self
[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(self, redirect_url: RedirectUrl) -> Self
[src]
Sets the the redirect URL used by the authorization endpoint.
pub fn authorize_url<F>(&self, state_fn: F) -> (Url, CsrfToken) where
F: FnOnce() -> CsrfToken,
[src]
F: FnOnce() -> CsrfToken,
Produces the full authorization URL used by the Authorization Code Grant flow, which is the most common OAuth2 flow.
Arguments
state_fn
- A function that returns an opaque value used by the client to maintain state between the request and callback. 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. To disable CSRF protections (NOT recommended), use insecure::authorize_url
instead.
pub fn authorize_url_implicit<F>(&self, state_fn: F) -> (Url, CsrfToken) where
F: FnOnce() -> CsrfToken,
[src]
F: FnOnce() -> CsrfToken,
Produces the full authorization URL used by the Implicit Grant flow.
Arguments
state_fn
- A function that returns an opaque value used by the client to maintain state between the request and callback. 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. To disable CSRF protections (NOT recommended), use
insecure::authorize_url_implicit
instead.
pub fn authorize_url_extension<F, T>(
&self,
response_type: &ResponseType,
state_fn: F,
extra_params: &[(&str, T)]
) -> (Url, CsrfToken) where
F: FnOnce() -> CsrfToken,
T: AsRef<str> + Clone,
[src]
&self,
response_type: &ResponseType,
state_fn: F,
extra_params: &[(&str, T)]
) -> (Url, CsrfToken) where
F: FnOnce() -> CsrfToken,
T: AsRef<str> + Clone,
Produces the full authorization URL used by an OAuth2 extension.
Arguments
response_type
- The response type this client expects from the authorization endpoint. For"code"
or"token"
response types, instead use theauthorize_url
orauthorize_url_implicit
functions, respectively.state_fn
- A function that returns an opaque value used by the client to maintain state between the request and callback. The authorization server includes this value when redirecting the user-agent back to the client.extra_params
- Additional parameters as required by the applicable OAuth2 extension(s). Callers should NOT specify any of the following parameters:response_type
,client_id
,redirect_uri
, orscope
.
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.
Callers should follow the security recommendations for any OAuth2 extensions used with this function, which are beyond the scope of RFC 6749.
pub fn exchange_code(
&self,
code: AuthorizationCode
) -> Result<TR, RequestTokenError<TE>>
[src]
&self,
code: AuthorizationCode
) -> Result<TR, RequestTokenError<TE>>
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_code_extension<T>(
&self,
code: AuthorizationCode,
extra_params: &[(&str, T)]
) -> Result<TR, RequestTokenError<TE>> where
T: AsRef<str> + Clone,
[src]
&self,
code: AuthorizationCode,
extra_params: &[(&str, T)]
) -> Result<TR, RequestTokenError<TE>> where
T: AsRef<str> + Clone,
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(
&self,
username: &ResourceOwnerUsername,
password: &ResourceOwnerPassword
) -> Result<TR, RequestTokenError<TE>>
[src]
&self,
username: &ResourceOwnerUsername,
password: &ResourceOwnerPassword
) -> Result<TR, RequestTokenError<TE>>
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) -> Result<TR, RequestTokenError<TE>>
[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
) -> Result<TR, RequestTokenError<TE>>
[src]
&self,
refresh_token: &RefreshToken
) -> Result<TR, RequestTokenError<TE>>
Exchanges a refresh token for an access token
See https://tools.ietf.org/html/rfc6749#section-6
pub fn exchange_refresh_token_extension<T>(
&self,
refresh_token: &RefreshToken,
extra_params: &[(&str, T)]
) -> Result<TR, RequestTokenError<TE>> where
T: AsRef<str> + Clone,
[src]
&self,
refresh_token: &RefreshToken,
extra_params: &[(&str, T)]
) -> Result<TR, RequestTokenError<TE>> where
T: AsRef<str> + Clone,
Exchanges a refresh token for an access token
See https://tools.ietf.org/html/rfc6749#section-6
Trait Implementations
impl<TE: Clone, TR: Clone, TT: Clone> Clone for Client<TE, TR, TT> where
TE: ErrorResponseType,
TR: TokenResponse<TT>,
TT: TokenType,
[src]
TE: ErrorResponseType,
TR: TokenResponse<TT>,
TT: TokenType,
fn clone(&self) -> Client<TE, TR, TT>
[src]
default fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<TE: Debug, TR: Debug, TT: Debug> Debug for Client<TE, TR, TT> where
TE: ErrorResponseType,
TR: TokenResponse<TT>,
TT: TokenType,
[src]
TE: ErrorResponseType,
TR: TokenResponse<TT>,
TT: TokenType,
Auto Trait Implementations
impl<TE, TR, TT> Send for Client<TE, TR, TT> where
TR: Send,
TT: Send,
TR: Send,
TT: Send,
impl<TE, TR, TT> Sync for Client<TE, TR, TT> where
TR: Sync,
TT: Sync,
TR: Sync,
TT: Sync,
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom 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> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto 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<T> Same for T
type Output = T
Should always be Self