• 
      

    Add flexibility and time-sensitivity when creating client API tokens.

    Review Request #15104 — Created June 7, 2026 and updated

    Information

    Review Board
    release-8.x

    Reviewers

    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_data and 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
    Add flexibility and time-sensitivity when creating client API tokens.
    `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_data` and 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.
    6ac2dfdad291dfcf862c1d953cd20d5d1172a34d
    Description From Last Updated

    Typo: an -> and

    david david

    This isn't including ignore_deprecated in the args.

    david david

    This should be + timedelta, not -

    david david
    Checks run (2 succeeded)
    flake8 passed.
    JSHint passed.
    david
    1. 
        
    2. reviewboard/webapi/managers.py (Diff revision 1)
       
       
      Show all issues

      Typo: an -> and

    3. reviewboard/webapi/tests/test_managers.py (Diff revision 1)
       
       
       
       
       
      Show all issues

      This isn't including ignore_deprecated in the args.

    4. Show all issues

      This should be + timedelta, not -

    5.