https://pypi.org/project/drf-advanced-token-manager/
A UI for users to manage their own tokens with the DRF Advanced Token Package (https://github.com/amp89/drf_advanced_token)
pip install --upgrade drf-advanced-token-manager
- make sure the DRF Advanced Token Package is installed (https://github.com/amp89/drf_advanced_token)
- Add
drf_advanced_token_manager
underdrf_advanced_token
in INSTALLED_APPS settings:
...
'drf_advanced_token',
'drf_advanced_token_manager',
...
- Set
SITE_HOME_URL_NAME
in settings to the name of the url that is the root / base site of your project - [OPTIONAL] If you don't want the user to be able to change their own token, add
PREVENT_TOKEN_UI_CHANGE=True
- Add
path('token_manager/', include('drf_advanced_token_manager.urls')),
to your baseurls.py
urlpatterns
The added urls are now:
View token: token_manager/
(name='drf_advanced_token_manager.view'
) (This is the UI where the user can manage their token.)
Change token: token_manager/change/
(name='drf_advanced_token_manager.change'
) (Note: There is a link to this in the view url above!)
- Create an
UserUIKeyLock
object in the admin panel to lock a user's API key from being changed from the UI (Can still be changed from the API)