python - 无法使用 python 社交身份验证设置自定义参数

标签 python django python-social-auth

我已按照文档设置自定义参数,但仍然无法从自定义管道函数中获取它。

这是设置:

在settings.py中:

FIELDS_STORED_IN_SESSION = ['tgtid']

SOCIAL_AUTH_PIPELINE = (
    'mindex.users.auth.pipeline.user_data',
    'social.pipeline.social_auth.auth_allowed',
    'social.pipeline.social_auth.social_user',
    'social.pipeline.user.create_user',
    'social.pipeline.social_auth.associate_user',
    'social.pipeline.user.user_details',
    'mindex.users.auth.pipeline.save_token',
    'mindex.users.auth.pipeline.add_social',
)

重定向网址示例为:

/login/facebook/?tgtid=1&next=/report/1/connect_task/

在我的 add_social 函数中,我无法读取 tgtid,strategy.session_get('tgtid') 返回 None。 add_social函数的签名是:

add_social(strategy, social, response, *args, **kwargs)

最佳答案

我已经弄清楚了。

只需将以下行添加到settings.py:

SOCIAL_AUTH_FIELDS_STORED_IN_SESSION = ('tgtid', )

关于python - 无法使用 python 社交身份验证设置自定义参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27368794/

相关文章:

python - 在python中将字符串解析为时间值

python - 在 Django 请求 header 中访问用户名和密码返回 None

python - 在 VS Code 中选择 python 解释器时出现错误 : spawn ENOTDIR,

python - update_or_create 循环中仅更新/创建数据库中的一行

python - Django:celery 任务不使用 .delay() 执行

django - 检查当前用户是否使用任何 django 社交身份验证提供程序登录

python - 为什么 'pip install mysqlclient' 在 ubuntu 18.04 LTS 中不工作

python - __repr__ 方法出现无法为 Exception 类自动调用

python - 在 python-social-auth 中从 google 和 facebook 检索个人资料图片

Python-Social-Auth 有时显示 'AuthStateForbidden'