Jeff Brainerd
06/25/2020, 5:23 PMagent.py
that the container env should include the env var: "PREFECT__CLOUD__AUTH_TOKEN": config.cloud.agent.auth_token,
So at this point Iām not sure if that value is not set, or it is set correctly but the agent token doesnāt have the correct auth. PS ā I am open to doing this another way, such as a dedicated SlackTask, but the state handler seems somehow more semantically correct, and the CloudHook doesnāt seem to provide that kind of detailed info. (Sorry for the long post.) Thanks! šJeff Brainerd
06/25/2020, 5:24 PMAuthorizationError([{'path': ['switch_tenant'], 'message': 'Unauthenticated', 'extensions': {'code': 'UNAUTHENTICATED'}}])
Chris White
Jeff Brainerd
06/25/2020, 5:51 PMapi_token = os.getenv('PREFECT__CLOUD__AUTH_TOKEN')
_prefect_client = Client(api_token=api_token)
_prefect_client.login_to_tenant(tenant_slug="jellyfish")
Thereās more code, of course, but I think this is the relevant stuff. LMK if thereās something else of interest.Chris White
_prefect_client = Client()
and donāt call the login_to_tenant
route at all; let me know if that works, and if it does, Iāll explain whatās happeningJeff Brainerd
06/25/2020, 5:53 PMJeff Brainerd
06/25/2020, 9:59 PMChris White
login_to_tenant
is a route that is only supported for Personal Access tokens (these are tokens that identify you as a user, but do not identify the tenant that you want to work within)
- RUNNER tokens (which are the ones present in your environment anytime an agent submits your flow run) already have a tenant associated with them, but no user (theyāre kind of like āservice accountā tokens)
- because the Client
infers auth info from the environment, and because agents ensure your environment is Cloud-compatible, instantiating a Client within a Flow will ādo the right thingā and begin using the RUNNER tokenChris White
Marvin
06/25/2020, 11:13 PMJeff Brainerd
06/26/2020, 1:06 AM