python - 身份验证后无法让 python-social-auth 重定向到我的自定义 url
问题描述
我想python-social-auth
重定向到/?ref=twitter
用户是否通过 twitter 登录,以及/?ref=google
他们是否通过 google-oauth2 登录。
我使用安装了python-social-auth
库的 django 版本
pip install social-auth-app-django
到目前为止,身份验证有效,但python-social-auth
始终重定向到/
(即“家”)。
这是我的设置:
LOGIN_URL = 'login'
LOGOUT_URL = 'logout'
LOGIN_REDIRECT_URL = 'home'
# Used to redirect the user once the auth process ended successfully. The value of ?next=/foo is used if it was present
SOCIAL_AUTH_LOGIN_REDIRECT_URL = '/'
SOCIAL_AUTH_TWITTER_LOGIN_REDIRECT_URL = '/?ref=twitter'
SOCIAL_AUTH_GOOGLE_OAUTH2_LOGIN_REDIRECT_URL = '/?ref=google'
# URL where the user will be redirected in case of an error
SOCIAL_AUTH_LOGIN_ERROR_URL = '/?err=true'
SOCIAL_AUTH_TWITTER_LOGIN_ERROR_URL = '/?ref=twitter&err=true'
SOCIAL_AUTH_GOOGLE_OAUTH2_LOGIN_ERROR_URL = '/?ref=google&err=true'
# Is used as a fallback for LOGIN_ERROR_URL
SOCIAL_AUTH_LOGIN_URL = '/'
SOCIAL_AUTH_TWITTER_LOGIN_URL = '/?ref=twitter'
SOCIAL_AUTH_GOOGLE_OAUTH2_LOGIN_URL = '/?ref=google'
# Used to redirect new registered users, will be used in place of SOCIAL_AUTH_LOGIN_REDIRECT_URL if defined.
# Note that ?next=/foo is appended if present, if you want new users to go to next, you'll need to do it yourself.
SOCIAL_AUTH_NEW_USER_REDIRECT_URL = '/?user=new'
SOCIAL_AUTH_TWITTER_NEW_USER_REDIRECT_URL = '/?ref=twitter&user=new'
SOCIAL_AUTH_GOOGLE_OAUTH2_NEW_USER_REDIRECT_URL = '/?ref=google&user=new'
# Like SOCIAL_AUTH_NEW_USER_REDIRECT_URL but for new associated accounts (user is already logged in).
# Used in place of SOCIAL_AUTH_LOGIN_REDIRECT_URL
SOCIAL_AUTH_NEW_ASSOCIATION_REDIRECT_URL = '/?assoc=true'
SOCIAL_AUTH_TWITTER_NEW_ASSOCIATION_REDIRECT_URL = '/?ref=twitter&assoc=true'
SOCIAL_AUTH_GOOGLE_OAUTH2_NEW_ASSOCIATION_REDIRECT_URL = '/?ref=google&assoc=true'
如果有人能指出我在这里做错了什么,那将非常有帮助。
我目前正在浏览他们的文档以寻找线索。
谢谢
解决方案
推荐阅读
- javascript - 如何在jstree中单独搜索第n个孩子
- android - 如何在 Android 应用程序中包含不同的语言
- excel - 时间自动刷新
- wordpress - 在媒体 wp api 中上传图片
- c - 我打印学生详细信息的 c 程序不起作用
- python - 在 Django 的详细视图中获取方法
- sql - 如果我对另一个表执行 INNER JOIN,为什么一个表的 SUM 会上升?
- fortran - 在 Fortran 中生成随机数
- php - PhpStorm 无法与 Xdebug 3 一起使用:已配置但 PhpStorm 未检测到 Xdebug
- jakarta-ee - 针对 Micro 和嵌入式运行时的 javax.ejb.TransactionRolledbackLocalException