Add flexibility and time-sensitivity when creating client API tokens.
Review Request #15104 — Created June 7, 2026 and updated
WebAPIToken.objects.get_or_create_client_token()can now be given a
Local Site for filtering or creating tokens, as well as a default
extra_dataand a default token policy for new tokens. This gives
callers more control over the resulting token.It also now takes a
min_validity_secs, which specifies the minimum
time an existing token must be valid in order to be considered. This
defaults to 5 minutes, which should be a good minimum default for
anything that may need to perform an immediate operation. Callers can
pass in a longer validity window.
Unit tests pass.
| Summary | ID |
|---|---|
| f41dbf6a99199c0ff7f488fb862ccef2f9944bb4 |
Review request changed
- Change Summary:
-
- Added the missing
ignore_deprecated=Truein the test, and fixed the results. - Fixed a time delta.
- Fixed a typo.
- Added the missing
- Commits:
-
Summary ID 6ac2dfdad291dfcf862c1d953cd20d5d1172a34d f41dbf6a99199c0ff7f488fb862ccef2f9944bb4
Checks run (2 succeeded)
flake8
passed.
JSHint
passed.