pub struct OAuthProvider { /* private fields */ }Expand description
Builder-like representation of an OAuth identity provider.
The provider stores configuration (scopes, custom parameters, language hints)
and creates OAuthRequest instances that can be routed through the popup
or redirect handlers registered on Auth.
Implementations§
Source§impl OAuthProvider
impl OAuthProvider
Sourcepub fn new(
provider_id: impl Into<String>,
authorization_endpoint: impl Into<String>,
) -> Self
pub fn new( provider_id: impl Into<String>, authorization_endpoint: impl Into<String>, ) -> Self
Creates a new provider with the given ID and authorization endpoint.
Sourcepub fn provider_id(&self) -> &str
pub fn provider_id(&self) -> &str
Returns the provider identifier (e.g. google.com).
Returns the full authorization endpoint URL.
Sourcepub fn custom_parameters(&self) -> &HashMap<String, String>
pub fn custom_parameters(&self) -> &HashMap<String, String>
Returns any custom query parameters used when initiating flows.
Sourcepub fn display_name(&self) -> Option<&str>
pub fn display_name(&self) -> Option<&str>
Returns an optional user-facing display name for the provider.
Sourcepub fn language_code(&self) -> Option<&str>
pub fn language_code(&self) -> Option<&str>
Returns the preferred language hint for provider UX.
Sourcepub fn add_scope(&mut self, scope: impl Into<String>)
pub fn add_scope(&mut self, scope: impl Into<String>)
Adds a scope to the provider if it has not been added yet.
Sourcepub fn set_scopes<I, S>(&mut self, scopes: I)
pub fn set_scopes<I, S>(&mut self, scopes: I)
Replaces the provider scopes with the provided list.
Sourcepub fn set_custom_parameters(
&mut self,
parameters: HashMap<String, String>,
) -> &mut Self
pub fn set_custom_parameters( &mut self, parameters: HashMap<String, String>, ) -> &mut Self
Overwrites the custom parameters included in authorization requests.
Sourcepub fn set_display_name(&mut self, value: impl Into<String>) -> &mut Self
pub fn set_display_name(&mut self, value: impl Into<String>) -> &mut Self
Sets the user-visible display name.
Sourcepub fn set_language_code(&mut self, value: impl Into<String>) -> &mut Self
pub fn set_language_code(&mut self, value: impl Into<String>) -> &mut Self
Sets the preferred language hint passed to the provider.
Sourcepub fn build_request(&self, auth: &Auth) -> AuthResult<OAuthRequest>
pub fn build_request(&self, auth: &Auth) -> AuthResult<OAuthRequest>
Builds the OAuthRequest that will be passed to popup/redirect handlers.
Sourcepub fn sign_in_with_popup(&self, auth: &Auth) -> AuthResult<UserCredential>
pub fn sign_in_with_popup(&self, auth: &Auth) -> AuthResult<UserCredential>
Runs the configured popup handler and returns the produced credential. Executes the sign-in flow using a popup handler.
Sourcepub fn link_with_popup(&self, auth: &Auth) -> AuthResult<UserCredential>
pub fn link_with_popup(&self, auth: &Auth) -> AuthResult<UserCredential>
Links the current user with this provider using a popup flow.
Sourcepub fn sign_in_with_redirect(&self, auth: &Auth) -> AuthResult<()>
pub fn sign_in_with_redirect(&self, auth: &Auth) -> AuthResult<()>
Delegates to the redirect handler to start a redirect based flow.
Sourcepub fn link_with_redirect(&self, auth: &Auth) -> AuthResult<()>
pub fn link_with_redirect(&self, auth: &Auth) -> AuthResult<()>
Initiates a redirect flow to link the current user with this provider.
Sourcepub fn get_redirect_result(auth: &Auth) -> AuthResult<Option<UserCredential>>
pub fn get_redirect_result(auth: &Auth) -> AuthResult<Option<UserCredential>>
Completes a redirect flow using the registered redirect handler.
The provider does not influence result parsing at this stage; the handler is responsible for decoding whichever callback mechanism the hosting platform uses.
Trait Implementations§
Source§impl Clone for OAuthProvider
impl Clone for OAuthProvider
Source§fn clone(&self) -> OAuthProvider
fn clone(&self) -> OAuthProvider
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more