Passing a dynamic state parameter using django-allauth during social login

荒凉一梦 提交于 2019-12-02 17:19:35

问题


I need to pass data through a social authentication (so I can access it after the login is complete) using django-allauth, but I'm not sure how to go about doing this as the documentation seems to be completely lacking in this area.

From what I gather, OAuth2 accepts a state parameter that can be used to transfer this sort of data. After spending hours trolling through the django-allauth code, it appears that there might be some ability to append a dynamic state parameter. However, I have no idea what the proper way to introduce this data into the request is, nor at what point this should occur. Do I need to monkey patch something in socialaccounts/views.py? Unfortunately it doesn't seems like the socialaccounts adapter.py has any way to hook into a request like this.

Edit: It looks like there's also some opportunity to access the state parameter here, but again, I'm unsure of the best way to do this.


回答1:


It turns out the state parameters were a red herring; however, django-allauth passes the Django session ID through OAuth requests. This allows you to store data safely in request.session before the authentication occurs, and then access it again later after authentication is complete.



来源:https://stackoverflow.com/questions/31412369/passing-a-dynamic-state-parameter-using-django-allauth-during-social-login

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!