pub struct OAuthConfig {
pub client_id: String,
pub client_secret: Option<Secret>,
pub authorization_endpoint: String,
pub token_endpoint: String,
pub scopes: Vec<String>,
pub extra_authorization_params: Vec<(String, String)>,
}Expand description
Everything needed to talk to one OAuth provider.
Fields§
§client_id: String§client_secret: Option<Secret>Present only for confidential clients.
A desktop application cannot keep a secret from its user, so most providers issue public clients and PKCE replaces the secret entirely. When a provider insists on one, it is stored like any other credential.
token_endpoint: String§scopes: Vec<String>Provider-specific authorization parameters, e.g. Google’s
access_type=offline (without which no refresh token is issued).
Implementations§
Source§impl OAuthConfig
impl OAuthConfig
Sourcepub fn new(
client_id: impl Into<String>,
authorization_endpoint: impl Into<String>,
token_endpoint: impl Into<String>,
) -> Result<Self>
pub fn new( client_id: impl Into<String>, authorization_endpoint: impl Into<String>, token_endpoint: impl Into<String>, ) -> Result<Self>
Fails if either endpoint is not https:// — a plaintext authorization or token
endpoint lets a network observer read codes, tokens and (for a confidential
client) the client secret. Use OAuthConfig::insecure_for_testing for a local
provider double.
Sourcepub fn insecure_for_testing(
client_id: impl Into<String>,
authorization_endpoint: impl Into<String>,
token_endpoint: impl Into<String>,
) -> Self
pub fn insecure_for_testing( client_id: impl Into<String>, authorization_endpoint: impl Into<String>, token_endpoint: impl Into<String>, ) -> Self
Skips the HTTPS requirement OAuthConfig::new enforces. For a local provider
double in a test, never for a real endpoint — the override is a deliberate,
separate call so it cannot happen by omission.
pub fn with_scopes<S: Into<String>>( self, scopes: impl IntoIterator<Item = S>, ) -> Self
pub fn with_client_secret(self, secret: Secret) -> Self
Adds a provider-specific authorization parameter, e.g. Google’s
access_type=offline.
Fails if key is one the flow already sets itself (response_type, client_id,
redirect_uri, state, code_challenge, code_challenge_method, scope);
silently letting a later value win would mean a provider-specific param can
override state or code_challenge without that ever being a visible decision.
Trait Implementations§
Source§impl Clone for OAuthConfig
impl Clone for OAuthConfig
Source§fn clone(&self) -> OAuthConfig
fn clone(&self) -> OAuthConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more