我正在使用我的公司帳戶(即「Google for works」帳戶)實施Google oauth2。 0登錄到我的django應用程序。python-social-auth:在/ complete/google-oauth2 /中的AttributeError /:'NoneType'對象沒有屬性'provider'
管道在 「settings.py」 的模樣:
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',
]
添加條件後端到pipepline。
if config.GCPAuthentication.AUTO_CREATE_ACCOUNTS:
SOCIAL_AUTH_PIPELINE.extend([
'social.pipeline.user.get_username',
'social.pipeline.user.create_user'
])
在試圖登錄的第一次與一個新的用戶,我得到的錯誤:在/完整/谷歌的oauth2 AttributeError的/:「NoneType」對象有沒有屬性「供應商」
有趣的是,用戶正在創建並保存在數據庫中,並在下次登錄嘗試時允許我登錄。
它投擲的錯誤在這裏:https://github.com/omab/python-social-auth/blob/master/social/actions.py#L70
我公司谷歌帳戶可能沒有任何社會帳號(Google+已遭到停用)與它相關聯/相關的信息。這是一個問題嗎?
無論如何,你能告訴我任何解決方法來擺脫這個問題嗎?
get_username()和create_user()返回什麼? –
我該如何檢查? 在用戶中,獲取創建用戶名作爲我的電子郵件ID的新用戶,這是因爲我有, SOCIAL_AUTH_USERNAME_IS_FULL_EMAIL = True在settings.py –
我改變了函數管道的順序,它的工作: 我想它應該遵循這裏提到的方式是:https://github.com/omab/python-social-auth/blob/master/docs/pipeline.rst 謝謝@luke_aus。 –