Struct email::account::OAuth2Config
source · pub struct OAuth2Config {
pub method: OAuth2Method,
pub client_id: String,
pub client_secret: Secret,
pub auth_url: String,
pub token_url: String,
pub access_token: Secret,
pub refresh_token: Secret,
pub pkce: bool,
pub scopes: OAuth2Scopes,
pub redirect_host: String,
pub redirect_port: u16,
}
Expand description
The OAuth 2.0 configuration.
Fields§
§method: OAuth2Method
Method for presenting an OAuth 2.0 bearer token to a service for authentication.
client_id: String
Client identifier issued to the client during the registration process described by Section 2.2.
client_secret: Secret
Client password issued to the client during the registration process described by Section 2.2.
auth_url: String
URL of the authorization server’s authorization endpoint.
token_url: String
URL of the authorization server’s token endpoint.
access_token: Secret
Access token returned by the token endpoint and used to access protected resources.
refresh_token: Secret
Refresh token used to obtain a new access token (if supported by the authorization server).
pkce: bool
Enable the PKCE protection. The value must have a minimum length of 43 characters and a maximum length of 128 characters. Each character must be ASCII alphanumeric or one of the characters “-” / “.” / “_” / “~”.
scopes: OAuth2Scopes
Access token scope(s), as defined by the authorization server.
redirect_host: String
Host name of the client’s redirection endpoint.
redirect_port: u16
Host port of the client’s redirection endpoint.
Implementations§
source§impl OAuth2Config
impl OAuth2Config
sourcepub fn default_redirect_host() -> String
pub fn default_redirect_host() -> String
Returns the default redirect host name. Combines well with
serde’s default
and skip_serializing_if
macros.
sourcepub fn default_redirect_port() -> u16
pub fn default_redirect_port() -> u16
Returns the default redirect host port. Combines well with
serde’s default
and skip_serializing_if
macros.
sourcepub async fn configure(
&self,
get_client_secret: impl Fn() -> Result<String>
) -> Result<()>
pub async fn configure( &self, get_client_secret: impl Fn() -> Result<String> ) -> Result<()>
If the access token is not defined, runs the authorization code grant OAuth 2.0 flow in order to save the acces token and the refresh token if present.
sourcepub async fn refresh_access_token(&self) -> Result<String>
pub async fn refresh_access_token(&self) -> Result<String>
Runs the refresh access token OAuth 2.0 flow by exchanging a refresh token with a new pair of access/refresh token.
sourcepub async fn access_token(&self) -> Result<String>
pub async fn access_token(&self) -> Result<String>
Returns the access token if existing, otherwise returns an error.
Trait Implementations§
source§impl Clone for OAuth2Config
impl Clone for OAuth2Config
source§fn clone(&self) -> OAuth2Config
fn clone(&self) -> OAuth2Config
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for OAuth2Config
impl Debug for OAuth2Config
source§impl Default for OAuth2Config
impl Default for OAuth2Config
source§impl PartialEq<OAuth2Config> for OAuth2Config
impl PartialEq<OAuth2Config> for OAuth2Config
source§fn eq(&self, other: &OAuth2Config) -> bool
fn eq(&self, other: &OAuth2Config) -> bool
self
and other
values to be equal, and is used
by ==
.impl Eq for OAuth2Config
impl StructuralEq for OAuth2Config
impl StructuralPartialEq for OAuth2Config
Auto Trait Implementations§
impl RefUnwindSafe for OAuth2Config
impl Send for OAuth2Config
impl Sync for OAuth2Config
impl Unpin for OAuth2Config
impl UnwindSafe for OAuth2Config
Blanket Implementations§
§impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere Scheme: ApproxScheme,
§fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
§impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere Dst: ApproxFrom<Src, Scheme>, Scheme: ApproxScheme,
§fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Chain<T> for T
impl<T> Chain<T> for T
§impl<T> Chain<T> for T
impl<T> Chain<T> for T
§impl<T, Dst> ConvAsUtil<Dst> for T
impl<T, Dst> ConvAsUtil<Dst> for T
§impl<T> ConvUtil for T
impl<T> ConvUtil for T
§fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst, DefaultApprox>,
fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where Self: Sized + ApproxInto<Dst, DefaultApprox>,
§fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst, Scheme>,
Scheme: ApproxScheme,
fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>where Self: Sized + ApproxInto<Dst, Scheme>, Scheme: ApproxScheme,
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.