Thursday, 15 September 2011

python social auth - Facebook and linkedin not filling email field properly -



python social auth - Facebook and linkedin not filling email field properly -

google , github logins working reason cant facebook , linkedin accounts fill email fields.

here involved files

__init__.py db = sqlalchemy(app) login_manager=loginmanager() login_manager.init_app(app) # import blueprints app (example: app.posts import posts) app.users import users # register blueprints main app (example: app.register_blueprint(posts)) app.register_blueprint(users) app.register_blueprint(social_auth) #3rd part db interaction init_social(app, db) # import main views app app import views #set login bootback login_manager.login_view ='/login' app.context_processor(backends)

settings.py configuration, keys have been removed post

#flask secret_key = '' session_cookie_name = '' ### python social auth ### debug_tb_intercept_redirects = false session_protection = 'strong' #redirects , paths social_auth_login_url = '/login' social_auth_login_redirect_url = '/' social_auth_backend_error_url = '/login' social_auth_user_model = 'app.users.models.user' social_auth_username_is_full_email = true #facebook social_auth_facebook_key='' social_auth_facebook_secret='' #google social_auth_google_key='' social_auth_google_secret='' #linkedin social_auth_linkedin_key='' social_auth_linkedin_secret='' #github social_auth_github_key='' social_auth_github_secret='' social_auth_authentication_backends = ( 'social.backends.google.googleopenid', 'social.backends.google.googleoauth2', 'social.backends.google.googleoauth', 'social.backends.facebook.facebookoauth2', 'social.backends.linkedin.linkedinoauth', 'social.backends.github.githuboauth2', ) here model itself, follows pretty closely illustration provided omab

models.py

from __future__ import absolute_import, print_function time import time import functools import uuid import pbkdf2 marshmallow import serializer, fields app import db role_user=0 role_admin=1 role_god=2 default_img = '/assets/images/avatars/default.jpg' class user(db.model): #meat n' potatoes id = db.column(db.integer, primary_key=true) img=db.column(db.string(255), default=default_img) username = db.column(db.string(255)) email = db.column(db.string(200), unique=true) first_name = db.column(db.string(30)) last_name = db.column(db.string(40)) created_at = db.column(db.biginteger, default=time()) #controls role = db.column(db.smallinteger, default=role_user) is_active = db.column(db.boolean, default=true) is_authenticated= db.column(db.boolean, default=true) #password salt = db.column(db.string(50)) pass_hash = db.column(db.string(255)) def __unicode__(self): homecoming self.email def __repr__(self): homecoming '<user %r>' % self.email def is_authenticated(self): homecoming self.is_authenticated def is_anonymous(self): homecoming false def is_active(self): homecoming self.is_active def get_id(self): homecoming unicode(self.id) def _check_password(self, password): hash_check = pbkdf2.crypt(password, self.salt, 1000) if hash_check ==self.pass_hash: valid=true else: valid=false homecoming valid def validate_user(self,password): p=self.check_password(password=password) if p: homecoming true; else: homecoming false; meta = { 'allow_inheritance': true, 'indexes': ['-created_at'], 'ordering': ['-created_at'] } class userserializer(serializer): id=fields.integer() img=fields.string() email=fields.string() first_name=fields.string() last_name=fields.string()

found in docs silly of me not realize have different request parameters: http://psa.matiasaguirre.net/docs/backends/index.html

python-social-auth

No comments:

Post a Comment