pub struct OAuth2Config {
pub method: OAuth2Method,
pub client_id: String,
pub client_secret: Option<Secret>,
pub auth_url: String,
pub token_url: String,
pub access_token: Secret,
pub refresh_token: Secret,
pub pkce: bool,
pub redirect_scheme: Option<String>,
pub redirect_host: Option<String>,
pub redirect_port: Option<u16>,
pub scopes: OAuth2Scopes,
}
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: Option<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 “-” / “.” / “_” / “~”.
redirect_scheme: Option<String>
§redirect_host: Option<String>
§redirect_port: Option<u16>
§scopes: OAuth2Scopes
Access token scope(s), as defined by the authorization server.
Implementations§
Source§impl OAuth2Config
impl OAuth2Config
pub const LOCALHOST: &'static str = "localhost"
Sourcepub fn get_first_available_port() -> Result<u16>
pub fn get_first_available_port() -> Result<u16>
Return the first available port on [LOCALHOST
].
Sourcepub async fn reset(&self) -> Result<()>
pub async fn reset(&self) -> Result<()>
Resets the three secrets of the OAuth 2.0 configuration.
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§fn default() -> OAuth2Config
fn default() -> OAuth2Config
Source§impl<'de> Deserialize<'de> for OAuth2Config
impl<'de> Deserialize<'de> for OAuth2Config
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for OAuth2Config
impl PartialEq for OAuth2Config
Source§impl Serialize for OAuth2Config
impl Serialize for OAuth2Config
impl Eq for OAuth2Config
impl StructuralPartialEq for OAuth2Config
Auto Trait Implementations§
impl Freeze for OAuth2Config
impl !RefUnwindSafe for OAuth2Config
impl Send for OAuth2Config
impl Sync for OAuth2Config
impl Unpin for OAuth2Config
impl !UnwindSafe for OAuth2Config
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more