• 
      

    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.
    f41dbf6a99199c0ff7f488fb862ccef2f9944bb4
    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

    While it's unlikely that default_extra_data would include a client_name key, I feel like we should switch these just in case.

    david david
    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. 
        
    chipx86
    Review request changed
    Change Summary:
    • Added the missing ignore_deprecated=True in the test, and fixed the results.
    • Fixed a time delta.
    • Fixed a typo.
    Commits:
    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
    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.
    f41dbf6a99199c0ff7f488fb862ccef2f9944bb4

    Checks run (2 succeeded)

    flake8 passed.
    JSHint passed.
    maubin
    1. Ship It!
    2. 
        
    david
    1. 
        
    2. reviewboard/webapi/managers.py (Diff revision 2)
       
       
       
       
       
       
       
      Show all issues

      While it's unlikely that default_extra_data would include a client_name key, I feel like we should switch these just in case.

    3.