I am using my corporate account (which is "Google for works" account) to implement Google oauth2.0 login in to my django application.
Pipeline in "settings.py" looks like:
SOCIAL_AUTH_PIPELINE = [
'social.pipeline.social_auth.social_details',
'social.pipeline.social_auth.social_uid',
'social.pipeline.social_auth.auth_allowed',
'social.pipeline.social_auth.associate_by_email',
'social.pipeline.social_auth.associate_user',
'social.pipeline.social_auth.load_extra_data',
'social.pipeline.user.user_details',
]
Adding conditional backends to pipepline.
if config.GCPAuthentication.AUTO_CREATE_ACCOUNTS:
SOCIAL_AUTH_PIPELINE.extend([
'social.pipeline.user.get_username',
'social.pipeline.user.create_user'
])
While trying to login for the very first time with a new user, I am getting error: AttributeError at /complete/google-oauth2/: 'NoneType' object has no attribute 'provider'
And interestingly, user is getting created and saved in DB and on next login attempt it allows me to login.
Its throwing error here : https://github.com/omab/python-social-auth/blob/master/social/actions.py#L70
My corporate Google account might not have any social account(Google+ is disabled)/related info associated with it. Is that an issue?
In any case, can you please tell me any workaround to get rid of this issue?
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.
The pipeline expects to follow the order in which functions needs to be called. To my solution right sequence should be like:
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 newUSER
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.