- There are 3 new files you will need to add.
- You will need to vendor in django-oauth2-provider into your project.
Once done, add a folder in provider/oauth2
called ext
. In the end this path will exist: provider/oauth2/ext
.
Place the 3 files below into that folder with an __init__.py
Now it's time to integrate the new files into the existing file. There are 2 files we need to change ever so slightly:
- provider.oauth2.admin
- provider.oauth2.models
provider.oauth2.admin
We just need to register our custom admin form we added in the above 3 files:
# ... existing imports ...
from .ext import forms as x_forms
# ... existing code ...
class ClientAdmin(admin.ModelAdmin):
form = x_forms.x_ClientAdminForm
list_display = ('url', 'user', 'redirect_uri', 'client_id', 'client_type')
raw_id_fields = ('user',)
# ... existing code ...
provider.oauth2.models
# ... existing imports ...
from .ext import fields as x_models
# ... existing code ...
# We just need to change the redirect_uri field of the Client model to the following:
class Client(models.Model):
# ... existing fields ...
redirect_uri = x_models.x_URLField(help_text="Your application's callback URL")
# ... existing fields ...
# ... existing code ...
That's it.. you should now be able to set custom schemes from the admin UI