gpt4 book ai didi

Python Social Auth - 如何知道社交媒体连接是否成功?

转载 作者:太空宇宙 更新时间:2023-11-03 17:29:23 24 4
gpt4 key购买 nike

我已经安装了Python Social Auth。我用它来将用户网站帐户与其社交媒体帐户关联起来。

Facebook 连接链接是:

<a href="{% url 'social:begin' 'facebook' %}?next={{ request.path }}">Connect</a>

重定向有效,但如何知道社交媒体关联是否成功?

如果捕获异常,我可以显示 get_messages() 函数。这是完美的!但如果成功的话会返回。

我尝试自定义管道,但无法访问 request 变量来设置如下消息: messages.success(request, "Successful message!')

最佳答案

您确实可以访问自定义管道中的请求:

The pipeline functions will get quite a lot of arguments, ranging from the backend in use, different model instances, server requests and provider responses.

您可以阅读更多相关信息here .

您可以像这样访问request对象:

def custom_pipeline(strategy, *args, *kwargs):
request = strategy.request

并用消息做任何你想做的事。

关于Python Social Auth - 如何知道社交媒体连接是否成功?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32112402/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com