pub struct ProviderProfile {
pub id: Option<String>,
pub provider: Option<String>,
pub username: Option<String>,
pub name: Option<String>,
pub email: Option<String>,
pub email_verified: Option<bool>,
pub picture: Option<String>,
pub locale: Option<String>,
pub additional_data: HashMap<String, Value>,
}Expand description
Standardized user profile returned by an OAuth provider (all fields optional because different providers expose different sets of attributes).
For the application-level user model (structured, mandatory fields) see
crate::providers::ProviderProfile.
Fields§
§id: Option<String>Unique identifier from the provider
provider: Option<String>Provider that authenticated this user
username: Option<String>Username or login name
name: Option<String>Display name
email: Option<String>Email address
email_verified: Option<bool>Whether email is verified
picture: Option<String>Profile picture URL
locale: Option<String>Locale/language preference
additional_data: HashMap<String, Value>Provider-specific additional data
Implementations§
Source§impl ProviderProfile
impl ProviderProfile
Sourcepub fn with_provider(self, provider: impl Into<String>) -> Self
pub fn with_provider(self, provider: impl Into<String>) -> Self
Set provider
Sourcepub fn with_username(self, username: Option<impl Into<String>>) -> Self
pub fn with_username(self, username: Option<impl Into<String>>) -> Self
Set username
Sourcepub fn with_email(self, email: Option<impl Into<String>>) -> Self
pub fn with_email(self, email: Option<impl Into<String>>) -> Self
Set email
Sourcepub fn with_email_verified(self, verified: bool) -> Self
pub fn with_email_verified(self, verified: bool) -> Self
Set email verification status
Sourcepub fn with_picture(self, picture: Option<impl Into<String>>) -> Self
pub fn with_picture(self, picture: Option<impl Into<String>>) -> Self
Set profile picture URL
Sourcepub fn with_locale(self, locale: Option<impl Into<String>>) -> Self
pub fn with_locale(self, locale: Option<impl Into<String>>) -> Self
Set locale
Sourcepub fn with_additional_data(self, key: impl Into<String>, value: Value) -> Self
pub fn with_additional_data(self, key: impl Into<String>, value: Value) -> Self
Add additional provider-specific data
Sourcepub fn from_token_response(
token: &OAuthTokenResponse,
provider: &OAuthProvider,
) -> Option<Self>
pub fn from_token_response( token: &OAuthTokenResponse, provider: &OAuthProvider, ) -> Option<Self>
Create a new user profile from an OAuth token response
Sourcepub fn from_id_token(id_token: &str) -> Result<Self>
pub fn from_id_token(id_token: &str) -> Result<Self>
Extract a user profile from an ID token (JWT)
Sourcepub fn to_auth_token(&self, access_token: String) -> AuthToken
pub fn to_auth_token(&self, access_token: String) -> AuthToken
Create an AuthToken with this profile’s information.
If lifetime is None, defaults to 1 hour.
Sourcepub fn to_auth_token_with_lifetime(
&self,
access_token: String,
lifetime: Duration,
) -> AuthToken
pub fn to_auth_token_with_lifetime( &self, access_token: String, lifetime: Duration, ) -> AuthToken
Create an AuthToken with an explicit lifetime.
Sourcepub fn display_name(&self) -> Option<&str>
pub fn display_name(&self) -> Option<&str>
Get display name or fall back to username
Trait Implementations§
Source§impl Clone for ProviderProfile
impl Clone for ProviderProfile
Source§fn clone(&self) -> ProviderProfile
fn clone(&self) -> ProviderProfile
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ProviderProfile
impl Debug for ProviderProfile
Source§impl<'r> Decode<'r, Postgres> for ProviderProfile
Available on crate feature postgres-storage only.
impl<'r> Decode<'r, Postgres> for ProviderProfile
postgres-storage only.Source§fn decode(value: PgValueRef<'r>) -> Result<Self, BoxDynError>
fn decode(value: PgValueRef<'r>) -> Result<Self, BoxDynError>
Source§impl Default for ProviderProfile
impl Default for ProviderProfile
Source§impl<'de> Deserialize<'de> for ProviderProfile
impl<'de> Deserialize<'de> for ProviderProfile
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 Serialize for ProviderProfile
impl Serialize for ProviderProfile
Source§impl Type<Postgres> for ProviderProfile
Available on crate feature postgres-storage only.
impl Type<Postgres> for ProviderProfile
postgres-storage only.Source§fn type_info() -> PgTypeInfo
fn type_info() -> PgTypeInfo
Source§fn compatible(ty: &PgTypeInfo) -> bool
fn compatible(ty: &PgTypeInfo) -> bool
Auto Trait Implementations§
impl Freeze for ProviderProfile
impl RefUnwindSafe for ProviderProfile
impl Send for ProviderProfile
impl Sync for ProviderProfile
impl Unpin for ProviderProfile
impl UnsafeUnpin for ProviderProfile
impl UnwindSafe for ProviderProfile
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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<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