Associating multiple social accounts to one account

316 views
Skip to first unread message

Rajat Vij

unread,
Jul 1, 2015, 10:47:44 AM7/1/15
to python-so...@googlegroups.com
Hi,

I am trying to associate multiple social accounts to capture their information to a single account. I know the admin interface for Python Social Auth > User social auth allows us to do that.
But i am trying to create a page where after a user is logged in can login to his/her different social media accounts (say twitter, google, tumblr, flickr).
I know this might be a noob question as i have just started working on python few months back. Is there a way to do this? As when i try to log in to any social media account. I am forced logged out of the existing session and logged in to the social account by default.
To associate the account i have to go to admin screen then Python Social Auth > User social auth and change the user for each social account to the user it needs to associate to.

Is there a way from which i can maintain the session and override the following model to have user name from the existing session?

In social.apps.django_app.default.models.py

class UserSocialAuth(models.Model, DjangoUserMixin):
     """Social Auth association model"""
    user = models.ForeignKey(USER_MODEL, related_name='social_auth')  # here i need request.user instead, when the session is maintained
    .....


Is my approach correct? Or should i approach the problem in a different way?
If it is correct then, can anyone help as being the noob i am, i am sure that the only reason i am unable to do this is because of lack of skills.
Thanks and advance!!!

Rajat Vij

unread,
Jul 30, 2015, 2:32:12 PM7/30/15
to python-social-auth, rajat...@gmail.com
Is there anyone who had similar problem?
Any kind of help would be much appreciated.

Matías Aguirre

unread,
Jul 30, 2015, 4:10:28 PM7/30/15
to Rajat Vij, python-social-auth
Account association happens automatically, all you have to do is give
the link to the users. For example, user Foo logged in with Google in
your site, on his profile there's a link to associate his Twitter
(/login/twitter) and Facebook (/login/facebook) accounts, the user
clicks the links, follows the steps to associate the account (provider
login form, app approval, etc), then goes back to your site. Now the
user has two UserSocailAuth instances associated to his account.

Makes sense?
Matías
--
Matías Aguirre
http://matiasaguirre.net

Rajat Vij

unread,
Jul 30, 2015, 4:42:16 PM7/30/15
to python-social-auth, matias...@gmail.com
But when i am trying, i am getting logged out of the existing session and am returning to the site with the social media user credentials that is the account is not linked to the previously logged in account. Maybe i need to change my settings.py file for that. But i wasn't able to get around this.
 You can view my settings.py file here

Thanks for replying. 
Good to know that account associations happen automatically and i am doing something which is making behave like this.

Matías Aguirre

unread,
Jul 30, 2015, 4:49:54 PM7/30/15
to Rajat Vij, python-social-auth
That sounds like the account is already associated to another user,
try cleaning your database.

Rajat Vij

unread,
Aug 3, 2015, 11:58:03 AM8/3/15
to python-social-auth
Thanks. I got it working now. I forgot that before i was explicitely redirecting my login session to test something and forgot to change it in my settings file.
 And since i didn't know the default behavior i thought that this was because python social auth is made that way instead.
Once i knew this wasn't so i checked and found the problem.
Thanks for the help!
Reply all
Reply to author
Forward
0 new messages