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§
Methods from Deref<Target = BasicClient<EndpointSet, EndpointNotSet, EndpointNotSet, EndpointNotSet, EndpointSet>>§
Sourcepub fn auth_type(&self) -> &AuthType
pub fn auth_type(&self) -> &AuthType
Return the type of client authentication used for communicating with the authorization server.
Sourcepub fn redirect_uri(&self) -> Option<&RedirectUrl>
pub fn redirect_uri(&self) -> Option<&RedirectUrl>
Return the redirect URL used by the authorization endpoint.
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.
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.
Sourcepub fn exchange_client_credentials(
&self,
) -> ClientCredentialsTokenRequest<'_, TE, TR>
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.
Sourcepub fn exchange_code(
&self,
code: AuthorizationCode,
) -> CodeTokenRequest<'_, TE, TR>
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.
Sourcepub fn exchange_device_access_token<'a, EF>(
&'a self,
auth_response: &'a DeviceAuthorizationResponse<EF>,
) -> DeviceAccessTokenRequest<'a, 'static, TR, EF>where
EF: ExtraDeviceAuthorizationFields,
pub fn exchange_device_access_token<'a, EF>(
&'a self,
auth_response: &'a DeviceAuthorizationResponse<EF>,
) -> DeviceAccessTokenRequest<'a, 'static, TR, EF>where
EF: ExtraDeviceAuthorizationFields,
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.
Sourcepub fn exchange_password<'a>(
&'a self,
username: &'a ResourceOwnerUsername,
password: &'a ResourceOwnerPassword,
) -> PasswordTokenRequest<'a, TE, TR>
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.
Sourcepub fn exchange_refresh_token<'a>(
&'a self,
refresh_token: &'a RefreshToken,
) -> RefreshTokenRequest<'a, TE, TR>
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.
Sourcepub fn exchange_client_credentials(
&self,
) -> Result<ClientCredentialsTokenRequest<'_, TE, TR>, ConfigurationError>
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.
Sourcepub fn exchange_code(
&self,
code: AuthorizationCode,
) -> Result<CodeTokenRequest<'_, TE, TR>, ConfigurationError>
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.
Sourcepub fn exchange_device_access_token<'a, EF>(
&'a self,
auth_response: &'a DeviceAuthorizationResponse<EF>,
) -> Result<DeviceAccessTokenRequest<'a, 'static, TR, EF>, ConfigurationError>where
EF: ExtraDeviceAuthorizationFields,
pub fn exchange_device_access_token<'a, EF>(
&'a self,
auth_response: &'a DeviceAuthorizationResponse<EF>,
) -> Result<DeviceAccessTokenRequest<'a, 'static, TR, EF>, ConfigurationError>where
EF: ExtraDeviceAuthorizationFields,
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.
Sourcepub fn exchange_password<'a>(
&'a self,
username: &'a ResourceOwnerUsername,
password: &'a ResourceOwnerPassword,
) -> Result<PasswordTokenRequest<'a, TE, TR>, ConfigurationError>
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.
Sourcepub fn exchange_refresh_token<'a>(
&'a self,
refresh_token: &'a RefreshToken,
) -> Result<RefreshTokenRequest<'a, TE, TR>, ConfigurationError>
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.
Sourcepub fn exchange_device_code(&self) -> DeviceAuthorizationRequest<'_, TE>
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.
Return the RFC 8628 device authorization endpoint used for the Device Authorization Flow.
Sourcepub fn exchange_device_code(
&self,
) -> Result<DeviceAuthorizationRequest<'_, TE>, ConfigurationError>
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.
Return the RFC 8628 device authorization endpoint used for the Device Authorization Flow.
Sourcepub fn introspect<'a>(
&'a self,
token: &'a AccessToken,
) -> IntrospectionRequest<'a, TE, TIR>
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.
Sourcepub fn introspection_url(&self) -> &IntrospectionUrl
pub fn introspection_url(&self) -> &IntrospectionUrl
Return the RFC 7662 introspection endpoint.
Sourcepub fn introspect<'a>(
&'a self,
token: &'a AccessToken,
) -> Result<IntrospectionRequest<'a, TE, TIR>, ConfigurationError>
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.
Sourcepub fn introspection_url(&self) -> Option<&IntrospectionUrl>
pub fn introspection_url(&self) -> Option<&IntrospectionUrl>
Return the RFC 7662 introspection endpoint.
Sourcepub fn revoke_token(
&self,
token: RT,
) -> Result<RevocationRequest<'_, RT, TRE>, ConfigurationError>
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.
Sourcepub fn revocation_url(&self) -> &RevocationUrl
pub fn revocation_url(&self) -> &RevocationUrl
Return the RFC 7009 revocation endpoint.
See revoke_token()
.
Sourcepub fn revoke_token(
&self,
token: RT,
) -> Result<RevocationRequest<'_, RT, TRE>, ConfigurationError>
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.
Sourcepub fn revocation_url(&self) -> Option<&RevocationUrl>
pub fn revocation_url(&self) -> Option<&RevocationUrl>
Return the RFC 7009 revocation endpoint.
See revoke_token()
.