Skip to content

Commit c6e6598

Browse files
authored
Add info on TokenBlacklistView to the docs (jazzband#558)
1 parent d959114 commit c6e6598

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

docs/blacklist_app.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,28 @@ subclass instance and calling the instance's ``blacklist`` method:
4646
This will create unique outstanding token and blacklist records for the token's
4747
"jti" claim or whichever claim is specified by the ``JTI_CLAIM`` setting.
4848

49+
In a ``urls.py`` file, you can also include a route for ``TokenBlackListView``:
50+
51+
.. code-block:: python
52+
53+
from rest_framework_simplejwt.views import TokenBlacklistView
54+
55+
urlpatterns = [
56+
...
57+
path('api/token/blacklist/', TokenBlacklistView.as_view(), name='token_blacklist'),
58+
...
59+
]
60+
61+
It allows API users to blacklist tokens sending them to ``/api/token/blacklist/``, for example using curl:
62+
63+
.. code-block:: bash
64+
65+
curl \
66+
-X POST \
67+
-H "Content-Type: application/json" \
68+
-d '{"refresh":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoicmVmcmVzaCIsImV4cCI6MTY1MDI5NTEwOCwiaWF0IjoxNjUwMjA4NzA4LCJqdGkiOiJhYTY3ZDUxNzkwMGY0MTEyYTY5NTE0MTNmNWQ4NDk4NCIsInVzZXJfaWQiOjF9.tcj1_OcO1BRDfFyw4miHD7mqFdWKxmP7BJDRmxwCzrg"}' \
69+
http://localhost:8000/api/token/blacklist/
70+
4971
The blacklist app also provides a management command, ``flushexpiredtokens``,
5072
which will delete any tokens from the outstanding list and blacklist that have
5173
expired. You should set up a cron job on your server or hosting platform which

0 commit comments

Comments
 (0)