[Django]-Python-social-auth: AttributeError at /complete/google-oauth2/: 'NoneType' object has no attribute 'provider'

4πŸ‘

βœ…

The pipeline expects to follow the order in which functions needs to be called.
To my solution right sequence should be like:

SOCIAL_AUTH_PIPELINE = [  # Note: Sequence of functions matters here.
    'social.pipeline.social_auth.social_details',  # 0
    'social.pipeline.social_auth.social_uid',  # 1
    'social.pipeline.social_auth.auth_allowed',  # 2
    'social.pipeline.social_auth.social_user',  # 3
    'social.pipeline.user.get_username',  # 4
    'social.pipeline.social_auth.associate_by_email',  # 5
    'social.pipeline.social_auth.associate_user',  # 6
    'social.pipeline.social_auth.load_extra_data',  # 7
    'social.pipeline.user.user_details',  # 8
]

# Adding conditional functions to pipepline.
# NOTE: Sequence of functions matters here.
if config.GCPAuthentication.AUTO_CREATE_ACCOUNTS:
    SOCIAL_AUTH_PIPELINE.insert(6, 'social.pipeline.user.create_user')
πŸ‘€Nitin Verma

1πŸ‘

Yes you are right, Sequence of the function in the pipeline matters here as return of one function will be input to the next function in pipeline.

πŸ‘€gcpexpert

0πŸ‘

As a sidenote I want to add that I faced a similar issue when I updated my USER model by changing it’s primary key. In such scenarios, simply running migrations for the new USER model will not suffice. You will have to run migrations for the social auth as well. I did it by complete & forced migration of the entire project.

0πŸ‘

I had the same error coming from a corrupted local DB. I had to cleanup the tables: social_auth_usersocialauth and django_session.

πŸ‘€obotezat

Leave a comment