https://prefect.io logo
Title
j

jack

02/08/2022, 2:48 PM
What is the correct way to start the agent using an API key? Previously this worked:
prefect agent local start --token [some-token] --api <https://api.prefect.io>
But after generating an api KEY (not a token) and running a similar incantation:
prefect agent local start --token [THE-NEW-KEY] --api <https://api.prefect.io>
it complains with
prefect.utilities.exceptions.ClientError: [{'path': ['register_agent'], 'message': 'Unauthorized: permission error.', 'extensions': {'code': 'FORBIDDEN'}}]
k

Kevin Kho

02/08/2022, 2:52 PM
Token is deprecated. You’d want to make a new API key and then
prefect agent local start --key API_KEY
. But actually I think this should still work.
If you have multiple tenants, maybe try logging out?
prefect auth logout
and then try logging in again. We have a fix for this in the next release so you shouldn’t have to logout
j

jack

02/08/2022, 2:54 PM
When using the incantation you suggested, it gives this error:
Error: no such option: --key
k

Kevin Kho

02/08/2022, 3:01 PM
Ah ok. You are on a version below 0.15.0?
j

jack

02/08/2022, 3:03 PM
We're on 14.21 Do we need to upgrade?
k

Kevin Kho

02/08/2022, 3:05 PM
Can you try the
--token
but also do the logout first and take out any keys/tokens in the
config.toml
?
j

jack

02/08/2022, 3:08 PM
When running this:
prefect auth logout
it complains:
Error: Auth commands with server are not currently supported.
There is no config.toml for either of the users that execute prefect on this machine.
k

Kevin Kho

02/08/2022, 3:11 PM
Are you on server or cloud?
j

jack

02/08/2022, 3:12 PM
Cloud
There was a ~/.prefect/backend.toml file though that specified "server". So I deleted that file.
k

Kevin Kho

02/08/2022, 3:13 PM
Ah ok you can also do
prefect backend cloud
or
prefect backend server
to toggle. I think we should be good to try again
j

jack

02/08/2022, 3:20 PM
Found the issue... Our startup script was still calling
prefect backend server
even though we've been using cloud for months 🤷 The agent starts now using the
--token
argument with the newly generated KEY Thank you Kevin!
k

Kevin Kho

02/08/2022, 3:21 PM
Ah lol. Glad you figured it out!