Enable oauth login using django-allauth but custom provider

I created an oauth provider using django-oauth-toolkit .

Now I want to allow users of my client application to log in through this provider.

I understand that django-allauth is the perfect tool for this.

I see that django-allauth has a special folder for each provider, and there are special files in this folder called provider.py . For example, this is the folder for the github provider.

Should I create something similar to this folder specifically for my custom provider? Or is there an easier / better way to do this?

+7
python django oauth django-allauth
source share
1 answer

Based on what the documentation says, it discovers new providers based on INSTALLED_APPS . Therefore, you will need a Django application that has the same structure and includes providers.py . Therefore, you should be able to use a new application or an existing one.

This is from the docs :

If an existing provider does not meet your needs, you may need to set up a provider.

This can be achieved by subclassing your existing provider and creating your changes there. Providers are defined as django applications, so a typical setup would mean creating a django application in your project containing your customized urls.py, views.py and files.py. What behavior you can customize beyond the scope of this documentation.

In addition, a note about the contents of the providers.py file:

In your provider.py file, you will need to open the provider class using a module level attribute called provider_classes, with your custom classes listed. This allows your custom provider to be registered correctly based on the INSTALLED_APPS setting.

0
source share

All Articles