Skip to content

Store username of access token - #378

Merged
iLLiCiTiT merged 1 commit into
developfrom
enhancement/access-token-username
Nov 3, 2026
Merged

iLLiCiTiT merged 1 commit into
developfrom
enhancement/access-token-username

Conversation

@iLLiCiTiT

Copy link
Copy Markdown
Member

Changelog Description

Connection keeps the username of the access token owner, available as ServerAPI.access_token_username. It does not need an additional request.

con = ayon_api.get_server_api_connection()
con.access_token_username  # "john.doe", or None if the token is not valid

Additional info

Token validation already requests users/me but used only the status code, so the user was fetched again whenever the username was needed.

  • Username is stored on token validation and on login, and cleared when the token is reset.
  • If the username is not known yet (e.g. login response without user), the token is validated again once to get it.
  • The value is the token owner and is not affected by as_username. Use get_user to get the user requests are made as.
  • login and init_service use the new property instead of get_user.

Testing notes:

  1. Connect with a user token and with a service API key.
  2. con.access_token_username returns the same name as con.get_user()["name"] without an additional request.
  3. con.reset_token() makes it return None.

Token validation already requests 'users/me', so keep the username
from the response and expose it as 'ServerAPI.access_token_username'.
Use it in 'login' and 'init_service' instead of refetching the user.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@iLLiCiTiT iLLiCiTiT added the type: enhancement New feature or request label Nov 3, 2026
@iLLiCiTiT iLLiCiTiT self-assigned this Nov 3, 2026
@iLLiCiTiT
iLLiCiTiT merged commit a953b64 into develop Nov 3, 2026
3 checks passed
@iLLiCiTiT
iLLiCiTiT deleted the enhancement/access-token-username branch November 3, 2026 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant