pub struct OAuthConfig {
pub provider: String,
pub client_id: String,
pub client_secret: String,
pub redirect_uri: String,
}Fields§
§provider: String§client_id: String§client_secret: String§redirect_uri: StringImplementations§
Source§impl OAuthConfig
impl OAuthConfig
Sourcepub fn auth_url(&self) -> String
pub fn auth_url(&self) -> String
Generate the authorization URL for the provider.
Callers MUST append a &state=<random> parameter and validate it in the
callback to prevent CSRF attacks. See OAuthStateStore for a minimal
implementation.
Sourcepub fn auth_url_with_state(&self, state: &str) -> String
pub fn auth_url_with_state(&self, state: &str) -> String
Generate the authorization URL with a CSRF state parameter attached.
Sourcepub fn userinfo_url(&self) -> &str
pub fn userinfo_url(&self) -> &str
URL for the userinfo endpoint, which returns the authenticated user’s profile.
Sourcepub fn exchange_code_full(&self, code: &str) -> Result<TokenSet, String>
pub fn exchange_code_full(&self, code: &str) -> Result<TokenSet, String>
Exchange an authorization code for the full token set
(access_token, optional refresh_token, optional id_token,
expires_in, scope). The longer struct is what the
account-store needs to persist; the legacy
OAuthConfig::exchange_code returns just the access token for
callers that don’t care.
Sourcepub fn exchange_code(&self, code: &str) -> Result<String, String>
pub fn exchange_code(&self, code: &str) -> Result<String, String>
Exchange an authorization code for an access token. Thin wrapper
around OAuthConfig::exchange_code_full for callers that only
need the access token (existing pre-account-store call sites).
Sourcepub fn fetch_userinfo(
&self,
access_token: &str,
) -> Result<(String, Option<String>), String>
pub fn fetch_userinfo( &self, access_token: &str, ) -> Result<(String, Option<String>), String>
Fetch the authenticated user’s email + display name using an access token.
Returns (email, display_name). Use OAuthConfig::fetch_userinfo_full
when you also need the provider-stable account ID for account
linking — the (provider, provider_account_id) pair is what
keeps a renamed-email user matched to the same row.
Sourcepub fn fetch_userinfo_full(
&self,
access_token: &str,
) -> Result<UserInfo, String>
pub fn fetch_userinfo_full( &self, access_token: &str, ) -> Result<UserInfo, String>
Fetch the authenticated user’s full identity info — email + name +
the provider-stable account ID (Google’s sub, GitHub’s id).
provider_account_id is what the account-store keys on, NOT the
email; otherwise a user changing their Google address would orphan
their existing pylon account.
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