Skip to content

Commit

Permalink
Add info on TokenBlacklistView to the docs
Browse files Browse the repository at this point in the history
  • Loading branch information
inti7ary committed Apr 17, 2022
1 parent d959114 commit 2f1f6c6
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions docs/blacklist_app.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,28 @@ subclass instance and calling the instance's ``blacklist`` method:
This will create unique outstanding token and blacklist records for the token's
"jti" claim or whichever claim is specified by the ``JTI_CLAIM`` setting.

In your ``urls.py`` file you can also include a route for ``TokenBlackListView``:

.. code-block:: python
from rest_framework_simplejwt.views import TokenBlacklistView
urlpatterns = [
...
path('api/token/blacklist/', TokenBlacklistView.as_view(), name='token_blacklist'),
...
]
It allows API users to blacklist tokens sending them to /api/token/blacklist/, for example using curl:

.. code-block:: bash
curl \
-X POST \
-H "Content-Type: application/json" \
-d '{"refresh":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoicmVmcmVzaCIsImV4cCI6MTY1MDI5NTEwOCwiaWF0IjoxNjUwMjA4NzA4LCJqdGkiOiJhYTY3ZDUxNzkwMGY0MTEyYTY5NTE0MTNmNWQ4NDk4NCIsInVzZXJfaWQiOjF9.tcj1_OcO1BRDfFyw4miHD7mqFdWKxmP7BJDRmxwCzrg"}' \
http://localhost:8000/api/token/blacklist/
The blacklist app also provides a management command, ``flushexpiredtokens``,
which will delete any tokens from the outstanding list and blacklist that have
expired. You should set up a cron job on your server or hosting platform which
Expand Down

0 comments on commit 2f1f6c6

Please sign in to comment.