def _refresh_credentials_basic(flyte_client): """ This function is used by the _handle_rpc_error() decorator, depending on the AUTH_MODE config object. This handler is meant for SDK use-cases of auth (like pyflyte, or when users call SDK functions that require access to Admin, like when waiting for another workflow to complete from within a task). This function uses basic auth, which means the credentials for basic auth must be present from wherever this code is running. :param flyte_client: RawSynchronousFlyteClient :return: """ auth_endpoints = _credentials_access.get_authorization_endpoints(flyte_client.url) token_endpoint = auth_endpoints.token_endpoint client_secret = _basic_auth.get_secret() _logging.debug("Basic authorization flow with client id {} scope {}".format(_CLIENT_ID.get(), _SCOPE.get())) authorization_header = _basic_auth.get_basic_authorization_header(_CLIENT_ID.get(), client_secret) token, expires_in = _basic_auth.get_token(token_endpoint, authorization_header, _SCOPE.get()) _logging.info("Retrieved new token, expires in {}".format(expires_in)) flyte_client.set_access_token(token)
def test_get_secret(): import os os.environ[_CREDENTIALS_SECRET.env_var] = "abc" assert basic_auth.get_secret() == "abc"