Struct Client

Source
pub struct Client {
    pub redirect_host: String,
    pub redirect_port: u16,
    /* private fields */
}
Expand description

Client builder, used by other flows to send requests and build URLs.

Fields§

§redirect_host: String

Hostname of the client’s redirection endpoint.

§redirect_port: u16

Port of the client’s redirection endpoint.

Implementations§

Source§

impl Client

Source

pub fn new( client_id: impl ToString, client_secret: Option<impl ToString>, auth_url: impl ToString, token_url: impl ToString, redirect_scheme: impl ToString, redirect_host: impl ToString, redirect_port: impl Into<u16>, ) -> Result<Self>

Methods from Deref<Target = BasicClient<EndpointSet, EndpointNotSet, EndpointNotSet, EndpointNotSet, EndpointSet>>§

Source

pub fn client_id(&self) -> &ClientId

Return the Client ID.

Source

pub fn auth_type(&self) -> &AuthType

Return the type of client authentication used for communicating with the authorization server.

Source

pub fn redirect_uri(&self) -> Option<&RedirectUrl>

Return the redirect URL used by the authorization endpoint.

Source

pub fn auth_uri(&self) -> &AuthUrl

Return the authorization endpoint.

Source

pub fn authorize_url<S>(&self, state_fn: S) -> AuthorizationRequest<'_>
where S: FnOnce() -> CsrfToken,

Generate an authorization URL for a new authorization request.

Requires set_auth_uri() to have been previously called to set the authorization endpoint.

§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.

Source

pub fn auth_uri(&self) -> Option<&AuthUrl>

Return the authorization endpoint.

Source

pub fn authorize_url<S>( &self, state_fn: S, ) -> Result<AuthorizationRequest<'_>, ConfigurationError>
where S: FnOnce() -> CsrfToken,

Generate an authorization URL for a new authorization request.

Requires set_auth_uri_option() to have been previously called to set the authorization endpoint.

§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.

Source

pub fn exchange_client_credentials( &self, ) -> ClientCredentialsTokenRequest<'_, TE, TR>

Request an access token using the Client Credentials Flow.

Requires set_token_uri() to have been previously called to set the token endpoint.

Source

pub fn exchange_code( &self, code: AuthorizationCode, ) -> CodeTokenRequest<'_, TE, TR>

Exchange a code returned during the Authorization Code Flow for 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.

Requires set_token_uri() to have been previously called to set the token endpoint.

Source

pub fn exchange_device_access_token<'a, EF>( &'a self, auth_response: &'a DeviceAuthorizationResponse<EF>, ) -> DeviceAccessTokenRequest<'a, 'static, TR, EF>

Exchange an RFC 8628 Device Authorization Response returned by exchange_device_code() for an access token.

Requires set_token_uri() to have been previously called to set the token endpoint.

Source

pub fn exchange_password<'a>( &'a self, username: &'a ResourceOwnerUsername, password: &'a ResourceOwnerPassword, ) -> PasswordTokenRequest<'a, TE, TR>

Request an access token using the Resource Owner Password Credentials Flow.

Requires set_token_uri() to have been previously called to set the token endpoint.

Source

pub fn exchange_refresh_token<'a>( &'a self, refresh_token: &'a RefreshToken, ) -> RefreshTokenRequest<'a, TE, TR>

Exchange a refresh token for an access token.

See https://tools.ietf.org/html/rfc6749#section-6.

Requires set_token_uri() to have been previously called to set the token endpoint.

Source

pub fn token_uri(&self) -> &TokenUrl

Return the token endpoint.

Source

pub fn exchange_client_credentials( &self, ) -> Result<ClientCredentialsTokenRequest<'_, TE, TR>, ConfigurationError>

Request an access token using the Client Credentials Flow.

Requires set_token_uri_option() to have been previously called to set the token endpoint.

Source

pub fn exchange_code( &self, code: AuthorizationCode, ) -> Result<CodeTokenRequest<'_, TE, TR>, ConfigurationError>

Exchange a code returned during the Authorization Code Flow for 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.

Requires set_token_uri_option() to have been previously called to set the token endpoint.

Source

pub fn exchange_device_access_token<'a, EF>( &'a self, auth_response: &'a DeviceAuthorizationResponse<EF>, ) -> Result<DeviceAccessTokenRequest<'a, 'static, TR, EF>, ConfigurationError>

Exchange an RFC 8628 Device Authorization Response returned by exchange_device_code() for an access token.

Requires set_token_uri_option() to have been previously called to set the token endpoint.

Source

pub fn exchange_password<'a>( &'a self, username: &'a ResourceOwnerUsername, password: &'a ResourceOwnerPassword, ) -> Result<PasswordTokenRequest<'a, TE, TR>, ConfigurationError>

Request an access token using the Resource Owner Password Credentials Flow.

Requires set_token_uri_option() to have been previously called to set the token endpoint.

Source

pub fn exchange_refresh_token<'a>( &'a self, refresh_token: &'a RefreshToken, ) -> Result<RefreshTokenRequest<'a, TE, TR>, ConfigurationError>

Exchange a refresh token for an access token.

See https://tools.ietf.org/html/rfc6749#section-6.

Requires set_token_uri_option() to have been previously called to set the token endpoint.

Source

pub fn token_uri(&self) -> Option<&TokenUrl>

Return the token endpoint.

Source

pub fn exchange_device_code(&self) -> DeviceAuthorizationRequest<'_, TE>

Begin the RFC 8628 Device Authorization Flow and retrieve a Device Authorization Response.

Requires set_device_authorization_url() to have been previously called to set the device authorization endpoint.

See exchange_device_access_token().

Source

pub fn device_authorization_url(&self) -> &DeviceAuthorizationUrl

Return the RFC 8628 device authorization endpoint used for the Device Authorization Flow.

See exchange_device_code().

Source

pub fn exchange_device_code( &self, ) -> Result<DeviceAuthorizationRequest<'_, TE>, ConfigurationError>

Begin the RFC 8628 Device Authorization Flow.

Requires set_device_authorization_url_option() to have been previously called to set the device authorization endpoint.

See exchange_device_access_token().

Source

pub fn device_authorization_url(&self) -> Option<&DeviceAuthorizationUrl>

Return the RFC 8628 device authorization endpoint used for the Device Authorization Flow.

See exchange_device_code().

Source

pub fn introspect<'a>( &'a self, token: &'a AccessToken, ) -> IntrospectionRequest<'a, TE, TIR>

Retrieve metadata for an access token using the RFC 7662 introspection endpoint.

Requires set_introspection_url() to have been previously called to set the introspection endpoint.

Source

pub fn introspection_url(&self) -> &IntrospectionUrl

Return the RFC 7662 introspection endpoint.

Source

pub fn introspect<'a>( &'a self, token: &'a AccessToken, ) -> Result<IntrospectionRequest<'a, TE, TIR>, ConfigurationError>

Retrieve metadata for an access token using the RFC 7662 introspection endpoint.

Requires set_introspection_url_option() to have been previously called to set the introspection endpoint.

Source

pub fn introspection_url(&self) -> Option<&IntrospectionUrl>

Return the RFC 7662 introspection endpoint.

Source

pub fn revoke_token( &self, token: RT, ) -> Result<RevocationRequest<'_, RT, TRE>, ConfigurationError>

Revoke an access or refresh token using the RFC 7009 revocation endpoint.

Requires set_revocation_url() to have been previously called to set the revocation endpoint.

Source

pub fn revocation_url(&self) -> &RevocationUrl

Return the RFC 7009 revocation endpoint.

See revoke_token().

Source

pub fn revoke_token( &self, token: RT, ) -> Result<RevocationRequest<'_, RT, TRE>, ConfigurationError>

Revoke an access or refresh token using the RFC 7009 revocation endpoint.

Requires set_revocation_url_option() to have been previously called to set the revocation endpoint.

Source

pub fn revocation_url(&self) -> Option<&RevocationUrl>

Return the RFC 7009 revocation endpoint.

See revoke_token().

Trait Implementations§

Source§

impl Clone for Client

Source§

fn clone(&self) -> Client

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Client

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for Client

Auto Trait Implementations§

§

impl Freeze for Client

§

impl RefUnwindSafe for Client

§

impl Send for Client

§

impl Sync for Client

§

impl Unpin for Client

§

impl UnwindSafe for Client

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,