SocialApp
Represents a social application (OAuth client) configured for authentication.Fields
The provider type (e.g., “google”, “github”, “saml”).Max length: 30 characters
For providers that support subproviders (OpenID Connect, SAML), this ID identifies the specific instance. Social accounts originating from this app will have their
Optional: Yes
provider field set to provider_id if available, otherwise provider.Max length: 200 charactersOptional: Yes
Human-readable name for the application.Max length: 40 characters
OAuth client ID, app ID, or consumer key.Max length: 191 characters
API secret, client secret, or consumer secret.Max length: 191 characters
Optional: Yes
Optional: Yes
Additional key field for providers that require it.Max length: 191 characters
Optional: Yes
Optional: Yes
Additional provider-specific settings stored as JSON.Default:
{}Associated Django sites where this app can be used. Only available when
Optional: Yes
django.contrib.sites is enabled.Related model: sites.SiteOptional: Yes
Methods
get_provider()
The Django request object.
The provider instance configured with this app.
Manager Methods
objects.on_site()
The Django request object.
Social apps configured for the current site, or all apps if sites framework is disabled.
SocialAccount
Represents a user’s account with a social provider.Fields
The local user account associated with this social account.Related model:
On delete: CASCADE
AUTH_USER_MODELOn delete: CASCADE
The provider identifier. For accounts from a
SocialApp, this equals the app’s provider_id if available, otherwise provider.Max length: 200 charactersThe unique identifier for the user at the provider. This is the provider’s user ID.Max length: Configurable via
Unique: Together with
SOCIALACCOUNT_UID_MAX_LENGTH (default: 191)Unique: Together with
providerTimestamp of the last login using this social account.Auto-updated: Yes
Timestamp when this social account was first connected.Auto-created: Yes
Additional data from the provider (profile information, etc.).Default:
{}Methods
authenticate()
The authenticated user object.
get_profile_url()
The profile URL, or empty string if not available.
get_avatar_url()
The avatar URL, or empty string if not available.
get_provider()
Optional Django request object.
The provider instance.
get_provider_account()
Provider-specific account object.
SocialToken
Stores OAuth tokens for social accounts.Fields
The social application this token is for.Related model:
On delete: SET_NULL
Optional: Yes
SocialAppOn delete: SET_NULL
Optional: Yes
The social account this token belongs to.Related model:
On delete: CASCADE
SocialAccountOn delete: CASCADE
The OAuth token. For OAuth1, this is the
oauth_token. For OAuth2, this is the access token.The OAuth token secret. For OAuth1, this is the
oauth_token_secret. For OAuth2, this is the refresh token.Optional: YesWhen the access token expires.Optional: Yes
Meta
Combination of
app and account must be unique.SocialLogin
Represents a social user in the process of being logged in. This is a non-model class used during authentication flow.Attributes
The social account being logged in. May be unsaved.
The local user being logged in. May be unsaved.
Optional access token from the authentication handshake.
Email addresses retrieved from the provider.
State preserved during authentication. May be included in URLs, so do not store secrets here.
The provider instance handling this login.
Phone number retrieved from the provider, if available.
Whether the phone number has been verified by the provider.
Methods
__init__()
connect()
The Django request object.
The user to connect this social account to.
save()
The Django request object.
Whether this is a connection to an existing user.Default: False
lookup()
self.user if found.
Example:
serialize()
Dictionary containing all social login data.
deserialize()
Dictionary containing serialized social login data.
The deserialized SocialLogin instance.
get_redirect_url()
The Django request object.
The redirect URL, or None.
stash_state()
The Django request object.
State dictionary to stash. If None, extracts state from request.
State ID that can be used to retrieve the state later.
unstash_state()
The Django request object.
The unstashed state dictionary.
PermissionDeniedif no state is found.
Properties
is_existing
False if this represents a temporary account not yet saved to the database.
Example:
is_headless
True if this is a headless (API-based) authentication flow.
Example:
