Skip to content

Commit 4d51503

Browse files
outsbartsynasius
authored andcommitted
Added doc for cleartokens command
1 parent 2ee2b6a commit 4d51503

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ Index
3838
models
3939
advanced_topics
4040
settings
41+
management_commands
4142
glossary
4243

4344
.. toctree::

docs/management_commands.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Management commands
2+
===================
3+
4+
Django OAuth Toolkit exposes some useful management commands that can be run via shell or by other means (eg: cron)
5+
6+
.. _cleartokens:
7+
8+
cleartokens
9+
~~~~~~~~~~~
10+
11+
The ``cleartokens`` management command allows the user to remove those refresh tokens whose lifetime is greater than the
12+
amount specified by ``REFRESH_TOKEN_EXPIRE_SECONDS`` settings. It is important that this command is run regularly
13+
(eg: via cron) to avoid cluttering the database with expired refresh tokens.
14+
15+
If ``cleartokens`` runs daily the maximum delay before a refresh token is
16+
removed is ``REFRESH_TOKEN_EXPIRE_SECONDS`` + 1 day. This is normally not a
17+
problem since refresh tokens are long lived.
18+
19+
Note: Refresh tokens need to expire before AccessTokens can be removed from the
20+
database. Using ``cleartokens`` without ``REFRESH_TOKEN_EXPIRE_SECONDS`` has limited effect.

docs/settings.rst

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,7 @@ The name of the *write* scope.
9898
REFRESH_TOKEN_EXPIRE_SECONDS
9999
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
100100
The number of seconds before a refresh token gets removed from the database by
101-
the ``cleartokens``` management command. It's important that ``cleartokens``
102-
runs regularly (eg: via cron) in order for this setting to work.
103-
104-
If ``cleartokens`` runs daily the maximum delay before a refresh token is
105-
removed is ``REFRESH_TOKEN_EXPIRE_SECONDS`` + 1 day. This is normally not a
106-
problem since refresh tokens are long lived.
107-
108-
Note: Refresh tokens need to expire before AccessTokens can be removed from the
109-
database. Using ``cleartokens`` without ``REFRESH_TOKEN_EXPIRE_SECONDS`` has limited effect.
101+
the ``cleartokens`` management command. Check :ref:`cleartokens` management command for further info.
110102

111103
REQUEST_APPROVAL_PROMPT
112104
~~~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)