16

I have built an oauth provider using django-oauth-toolkit.

I would now like to allow users of my client application to log in through this provider.

My understanding is that django-allauth is the ideal tool for this.

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

Should I be creating something similar to this folder, specially for my custom provider ? Or is there an easier/better way to do this ?

Brachamul
  • 1,886
  • 2
  • 21
  • 34

2 Answers2

9

This is a interesting article that explains this topic:

8

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

This is from the 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.

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

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.

jaywhy13
  • 1,068
  • 12
  • 16