Skip to content

Fix get_user_by_token crash for valid tokens - #376

Open
BigRoy wants to merge 1 commit into
developfrom
bugfix/get-user-by-token-data
Open

BigRoy wants to merge 1 commit into
developfrom
bugfix/get-user-by-token-data

Conversation

@BigRoy

@BigRoy BigRoy commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Changelog Description

Fix get_user_by_token raising AttributeError for any valid token. It returned user_info.data, but UserInfo has no data field. It now returns the JSON of the /api/users/me response.

Additional info

Noted in #374, not fixed there.

The alternative is to expose data on UserInfo?

Testing notes:

Run this with a valid token or API key. Before the fix it raises AttributeError: 'UserInfo' object has no attribute 'data'; after, it prints the user name.

from ayon_api.utils import get_user_by_token

user = get_user_by_token("http://localhost:5000", "<your token or API key>")
print(user["name"])

An invalid token should still return None.

UserInfo has no 'data' field, so a valid token raised AttributeError.
Return the JSON of the '/api/users/me' response instead.
@BigRoy BigRoy added the type: bug Something isn't working label Nov 1, 2026
@BigRoy BigRoy self-assigned this Nov 1, 2026
@BigRoy
BigRoy requested a review from iLLiCiTiT November 1, 2026 00:11

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant