gpt4 book ai didi

python - 使用 django-allauth 启用 oauth 登录,但使用自定义提供程序

转载 作者:太空狗 更新时间:2023-10-29 20:29:58 28 4
gpt4 key购买 nike

我已经使用 django-oauth-toolkit 构建了一个 oauth 提供程序.

我现在想允许我的客户端应用程序的用户通过此提供商登录。

我的理解是django-allauth是这方面的理想工具。

我看到 django-allauth 为每个提供者都有一个特殊的文件夹,在这个文件夹中有一个名为 provider.py 的特殊文件。例如,this是 github 提供程序的文件夹。

我是否应该专门为我的自定义提供程序创建类似于此文件夹的内容?还是有更简单/更好的方法来做到这一点?

最佳答案

根据文档所述,它会根据 INSTALLED_APPS 发现新的提供程序。因此,您将需要一个具有相同结构的 Django 应用程序,并且包含一个 providers.py。因此,您应该能够使用新应用或现有应用。

这是来自 docs :

When an existing provider doesn’t quite meet your needs, you might find yourself needing to customize a provider.

This can be achieved by subclassing an existing provider and making your changes there. Providers are defined as django applications, so typically customizing one will mean creating a django application in your project, containing your customized urls.py, views.py and provider.py files. What behaviour you can customize is beyond the scope of this documentation.

此外,关于 providers.py 文件内容的注释:

In your provider.py file, you will need to expose the provider class by having a module level attribute called provider_classes with your custom classes in a list. This allows your custom provider to be registered properly on the basis of the INSTALLED_APPS setting.

关于python - 使用 django-allauth 启用 oauth 登录,但使用自定义提供程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37690418/

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