arthur_bench.client.auth#

Submodules#

arthur_bench.client.auth.helpers.get_arthur_internal_user_org(api_http_host: str, auth_token: str, verify_ssl: bool = True) str | None#
Get the current organization for the provided Arthur auth token belonging to an

Arthur internal user

Parameters:
  • api_http_host – base url of the host to connect to, including protocol (e.g. “https://app.arthur.ai”)

  • auth_token – auth token to pass to the API

  • verify_ssl – if True, verify that the SSL certificate is valid and not self-signed

Returns:

the organization ID associated with the provided access key, None if no such organization exists

Permissions:

N/A

arthur_bench.client.auth.helpers.get_auth_info(api_http_host: str, auth_token: str, verify_ssl: bool = True) AuthenticationInfo#

Get the AuthInfo struct associated with the provided access key

Parameters:

api_http_host – base url of the host to connect to, including protocol

(e.g. “https://app.arthur.ai”) :param auth_token: Token to fetch authentication info for :param verify_ssl: Boolean for whether requests should verify that the SSL certificate is valid and not self-signed :return: the AuthInfo associated with the provided access key :permissions: N/A

arthur_bench.client.auth.helpers.get_current_org(api_http_host: str, auth_token: str, verify_ssl: bool = True) str | None#

Get the current organization for the provided access key

Parameters:

api_http_host – base url of the host to connect to, including protocol

(e.g. “https://app.arthur.ai”) :param auth_token: API Key to pass to the API :param verify_ssl: Boolean for whether requests should verify that the SSL

certificate is valid and not self-signed

Returns:

the organization ID associated with the provided access key, None if no such organization exists

arthur_bench.client.auth.helpers.user_login(api_http_host: str, login: str, password: str, verify_ssl: bool = True) str#
Static convenience function to get a new auth token for the provided username and

password

Parameters:
  • api_http_host – base url of the host to connect to, including protocol (e.g. “https://app.arthur.ai”)

  • login – the username or password to use to log in

  • password – password for the user

  • verify_ssl – Boolean for whether requests should verify that the SSL certificate is valid and not self-signed

Returns:

an access_key

class arthur_bench.client.auth.refresh.AuthRefresher(url: str, login: str, password: str, verify_ssl: bool)#

Bases: object

ALGORITHMS = ['HS256']#
AUTH_KEY = 'Authorization'#
MINS_BEFORE_EXPIRY_TO_REFRESH = 5#
refresh() Tuple[Dict[str, str], timedelta]#

Authorization header update function for an HTTPClient

Fetches a new session token and returns the new token, and how long to wait before refreshing it (by calling this method again) :return: Headers to update (Authorization), and time to wait before refreshing

again