[−][src]Struct oauth2::Client
Stores the configuration for an OAuth2 client.
Implementations
impl<TE, TR, TT> Client<TE, TR, TT> where
TE: ErrorResponse + 'static,
TR: TokenResponse<TT>,
TT: TokenType,
[src]
TE: ErrorResponse + 'static,
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 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 set_device_authorization_url(
self,
device_authorization_url: DeviceAuthorizationUrl
) -> Self
[src]
self,
device_authorization_url: DeviceAuthorizationUrl
) -> Self
Sets the the device authorization URL used by the device authorization endpoint. Used for Device Code Flow, as per RFC 8628.
pub fn authorize_url<S>(&self, state_fn: S) -> AuthorizationRequest<'_> where
S: FnOnce() -> CsrfToken,
[src]
S: FnOnce() -> CsrfToken,
Generates an authorization URL for a new authorization request.
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 exchange_code(
&self,
code: AuthorizationCode
) -> CodeTokenRequest<'_, TE, TR, TT>
[src]
&self,
code: AuthorizationCode
) -> CodeTokenRequest<'_, TE, TR, TT>
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 once 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, 'b>(
&'a self,
username: &'b ResourceOwnerUsername,
password: &'b ResourceOwnerPassword
) -> PasswordTokenRequest<'b, TE, TR, TT> where
'a: 'b,
[src]
&'a self,
username: &'b ResourceOwnerUsername,
password: &'b ResourceOwnerPassword
) -> PasswordTokenRequest<'b, TE, TR, TT> where
'a: 'b,
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
) -> ClientCredentialsTokenRequest<'_, TE, TR, TT>
[src]
&self
) -> ClientCredentialsTokenRequest<'_, TE, TR, TT>
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<'a, 'b>(
&'a self,
refresh_token: &'b RefreshToken
) -> RefreshTokenRequest<'b, TE, TR, TT> where
'a: 'b,
[src]
&'a self,
refresh_token: &'b RefreshToken
) -> RefreshTokenRequest<'b, TE, TR, TT> where
'a: 'b,
Exchanges a refresh token for an access token
See https://tools.ietf.org/html/rfc6749#section-6
pub fn exchange_device_code(&self) -> DeviceAuthorizationRequest<'_, TE>
[src]
Perform a device authorization request as per https://tools.ietf.org/html/rfc8628#section-3.1
pub fn exchange_device_access_token<'a, 'b, 'c, EF>(
&'a self,
auth_response: &'b DeviceAuthorizationResponse<EF>
) -> DeviceAccessTokenRequest<'b, 'c, TR, TT, EF> where
'a: 'b,
EF: ExtraDeviceAuthorizationFields,
[src]
&'a self,
auth_response: &'b DeviceAuthorizationResponse<EF>
) -> DeviceAccessTokenRequest<'b, 'c, TR, TT, EF> where
'a: 'b,
EF: ExtraDeviceAuthorizationFields,
Perform a device access token request as per https://tools.ietf.org/html/rfc8628#section-3.4
Trait Implementations
impl<TE: Clone, TR: Clone, TT: Clone> Clone for Client<TE, TR, TT> where
TE: ErrorResponse,
TR: TokenResponse<TT>,
TT: TokenType,
[src]
TE: ErrorResponse,
TR: TokenResponse<TT>,
TT: TokenType,
impl<TE: Debug, TR: Debug, TT: Debug> Debug for Client<TE, TR, TT> where
TE: ErrorResponse,
TR: TokenResponse<TT>,
TT: TokenType,
[src]
TE: ErrorResponse,
TR: TokenResponse<TT>,
TT: TokenType,
Auto Trait Implementations
impl<TE, TR, TT> RefUnwindSafe for Client<TE, TR, TT> where
TE: RefUnwindSafe,
TR: RefUnwindSafe,
TT: RefUnwindSafe,
TE: RefUnwindSafe,
TR: RefUnwindSafe,
TT: RefUnwindSafe,
impl<TE, TR, TT> Send for Client<TE, TR, TT> where
TE: Send,
TR: Send,
TT: Send,
TE: Send,
TR: Send,
TT: Send,
impl<TE, TR, TT> Sync for Client<TE, TR, TT> where
TE: Sync,
TR: Sync,
TT: Sync,
TE: Sync,
TR: Sync,
TT: Sync,
impl<TE, TR, TT> Unpin for Client<TE, TR, TT> where
TE: Unpin,
TR: Unpin,
TT: Unpin,
TE: Unpin,
TR: Unpin,
TT: Unpin,
impl<TE, TR, TT> UnwindSafe for Client<TE, TR, TT> where
TE: UnwindSafe,
TR: UnwindSafe,
TT: UnwindSafe,
TE: UnwindSafe,
TR: UnwindSafe,
TT: UnwindSafe,
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>,