django.dispatch.Signal.
pre_social_login
Sent after a user successfully authenticates via a social provider, but before the login is actually processed.When Sent
This signal is emitted for:- Social logins (existing accounts)
- Social signups (new accounts)
- Connecting additional social accounts to an existing account
Parameters
HttpRequest
The Django request object for the current authentication flow.
SocialLogin
The
SocialLogin instance containing:account- The social account (may be unsaved)user- The user being logged in (may be unsaved)token- OAuth token if availableemail_addresses- List of email addresses from provider
Use Cases
- Auto-connect social accounts based on email
- Enforce business rules before login
- Block authentication based on conditions
- Populate additional user data
- Implement custom account linking logic
Example: Auto-connect by Email
Example: Block Authentication
Example: Populate User Profile
social_account_added
Sent after a user successfully connects a social account to their local account.When Sent
This signal is emitted when:- A logged-in user adds a new social account connection
- Auto-connection happens via email matching
Parameters
HttpRequest
The Django request object.
SocialLogin
The
SocialLogin instance for the newly connected account.Use Cases
- Send notification emails
- Log account connections
- Update user permissions
- Trigger webhooks
- Sync data with external systems
Example: Log Connections
Example: Send Custom Notification
Example: Trigger Webhook
social_account_updated
Sent when a user connects an already existing social account (token refresh and data update).When Sent
This signal is emitted when:- User logs in with a social account that’s already connected
- The account’s token and extra_data are refreshed
Parameters
HttpRequest
The Django request object.
SocialLogin
The
SocialLogin instance with updated token and data.Use Cases
- Sync updated profile data
- Track login frequency
- Update cached user information
- Monitor token refreshes
Example: Sync Profile Updates
Example: Track Login Analytics
social_account_removed
Sent after a user disconnects a social account from their local account.When Sent
This signal is emitted when:- User explicitly disconnects a social account
- Admin deletes a social account connection
Parameters
HttpRequest
The Django request object.
SocialAccount
The
SocialAccount instance that was removed.Note: This is a SocialAccount, not a SocialLogin.Use Cases
- Send notification emails
- Log disconnections for audit trail
- Clean up related data
- Revoke provider tokens
- Trigger security alerts
Example: Log Disconnections
Example: Send Security Alert
Example: Clean Up Related Data
Signal Registration
Signals should be registered in your app’sapps.py:
