websauna.system.user.social module¶
Bases:
object
Base class for mapping internal users to social network (OAuth) users.
Checks to perform when the user becomes a valid user for the first time.
If this user has already started sign up process through email we need to cancel that.
Create a new blank user instance as we could not find matching user with the existing details.
Check if we have a matching user for the email already.
Given a user information returned by Authomatic, return an existing User object from our database or create one if it does not exists.
- Parameters
request (
Request
) – Pyramid request object.user (
User
) – A user returned by Authomatic.
- Return type
InterfaceClass
- Returns
User object.
This is the string we use to map configuration for the
Update internal user data on every login.
Bt default, sets user.user_data[“social”][“facebook”] or user.user_data[“social”][“yoursocialnetwork”] to reflect the raw data given us by
import_social_media_user()
.- Parameters
user (
InterfaceClass
) – User object.data (
dict
) – Normalized data.
Set the initial data on the user model.
When the user logs in from a social network for the first time (no prior logins with this email before) we fill in blanks in the user model with incoming data. Default action is not to set any items.
- Parameters
user (
InterfaceClass
) – User object.data (
dict
) – Normalized data.
Bases:
websauna.system.user.social.EmailSocialLoginMapper
Map and login Facebook OAuth users to internal users.
You must have application created in developers.facebook.com
The application must have its consumer_key and consumer_secret configured in the secrets config file.
For testing: The application must have one Web site platform configured in developers.facebook.com, pointing to http://localhost:8521/ and Valid OAuth redirect URLs to http://localhost:8521/login/facebook
Extract social media information from the Authomatic login result in order to associate the user account.
- Parameters
request (
Request
) – Pyramid request.result (
LoginResult
) – Login result from Authomatic.
- Return type
InterfaceClass
- Returns
User object.
Map Authomatic user information to a dictionary.
- Parameters
user (
User
) – A user returned by Authomatic.- Return type
- Returns
Mapping from authomatic.core.User.
Update internal user data on every login.
- Parameters
user (
InterfaceClass
) – User object.data (
dict
) – Normalized data.
Bases:
websauna.system.user.social.EmailSocialLoginMapper
Map and login Google OAuth users to internal users.
Extract social media information from the Authomatic login result in order to associate the user account.
- Parameters
request (
Request
) – Pyramid request.result (
LoginResult
) – Login result from Authomatic.
- Return type
InterfaceClass
- Returns
User object.
Map Authomatic user information to a dictionary.
ref: http://peterhudec.github.io/authomatic/reference/providers.html#authomatic.providers.oauth2.Google
- Parameters
user (
User
) – A user returned by Authomatic.- Returns
Mapping from authomatic.core.User.
Set the initial data on the user model.
- Parameters
user (
InterfaceClass
) – User object.data (
dict
) – Normalized data.
Bases:
Exception
Raised when social media login cannot proceed due to incomplete provided information.
E.g. we need email to map the user, but the Facebook doesn’t give us email because user doesn’t grant the permission.
Bases:
websauna.system.user.social.EmailSocialLoginMapper
Map Twitter OAuth users to internal users.
Extract social media information from the Authomatic login result in order to associate the user account.
- Parameters
request (
Request
) – Pyramid request.result (
LoginResult
) – Login result from Authomatic.
- Return type
InterfaceClass
- Returns
User object.
Map Authomatic user information to a dictionary.
Pass-through Twitter auth data to user_data[‘social’][‘twitter’]
- Parameters
user (
User
) – A user returned by Authomatic.- Returns
Mapping from authomatic.core.User.
Set the initial data on the user model.
- Parameters
user (
InterfaceClass
) – User object.data (
dict
) – Normalized data.