Skip to content

Commit

Permalink
added custom implementation of 'is_token_valid'
Browse files Browse the repository at this point in the history
  • Loading branch information
iLLiCiTiT committed Sep 18, 2023
1 parent 47e427f commit f96116f
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion common/ayon_common/connection/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from ayon_api.exceptions import UrlError
from ayon_api.utils import (
validate_url,
is_token_valid,
logout_from_server,
)

Expand Down Expand Up @@ -465,6 +464,28 @@ def create_global_connection():
)


def is_token_valid(url, token):
"""Check if token is valid.
Note:
This function is available in 'ayon_api', but does not support to
validate service api key, only user's token. The support will be
added in future PRs of 'ayon_api'.
The function also did not support timeout which could cause
'ayon_api.is_token_valid' to hang.
Args:
url (str): Server url.
token (str): User's token.
Returns:
bool: True if token is valid.
"""

api = ayon_api.ServerAPI(url, token)
return api.has_valid_token


def need_server_or_login() -> bool:
"""Check if server url or login to the server are needed.
Expand Down

0 comments on commit f96116f

Please sign in to comment.