在社交登录期间使用django-allauth传递动态状态参数 [英] Passing a dynamic state parameter using django-allauth during social login

查看:185
本文介绍了在社交登录期间使用django-allauth传递动态状态参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要通过社交认证传递数据(所以我可以在登录完成后使用django-allauth访问它),但是我不知道如何做到这一点,因为文档似乎完全缺乏这个区域。

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.

从我收集的内容中,OAuth2接受状态参数,可用于传输此类数据。经过django-allauth代码花费数小时后,似乎可能会附加一个动态状态参数。但是,我不知道将这些数据引入到请求中的正确方法是什么,也不知道应该发生什么。我需要在socialaccounts / views.py中进行猴子补丁吗?不幸的是,它似乎不像social.py count.py有任何方式挂钩这样的请求。

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.

编辑:看起来还有一些机会访问状态参数 here ,但是再次,我不确定这样做的最佳方式。

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.

推荐答案

事实证明,状态参数是一个红色的鲱鱼;然而,django-allauth通过OAuth请求传递Django会话ID。这样就可以在身份验证发生之前将数据安全地存储在 request.session 中,然后验证完成后再次访问。

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.

这篇关于在社交登录期间使用django-allauth传递动态状态参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆