https://prefect.io logo
p

Paulo Benatto

01/19/2022, 3:04 PM
Hi guys I have a newbie question. I want to inject my token in my LocalAgent.
Copy code
client = Client(api_token=token)
    client.register(flow, project_name=project)
    from prefect import config

    # this looks wrong 
    config.cloud.agent.auth_token = token

    LocalAgent(name=name).start()
using command line to start agent works fine: ā€¢ prefect auth login -t TOKEN ā€¢ prefect agent local start I would like to run the agent from python and inject the token in my agent šŸ¤” thanks
k

Kevin Kho

01/19/2022, 3:11 PM
So if you do
prefect auth login -k API_KEY
, I think the Python client should be able to fetch it. Note keys are deprecated
p

Paulo Benatto

01/19/2022, 3:18 PM
Copy code
prefect.utilities.exceptions.AuthorizationError: No agent API token provided.
k

Kevin Kho

01/19/2022, 3:39 PM
What Prefect version are you on?
p

Paulo Benatto

01/19/2022, 3:56 PM
I was on 0.14.21 0.14.21 - did not work 0.15.12 - it does work Thanks for that Kevin šŸ™‡ There is a way without calling
prefect auth login
?
the whole process using only python code?
k

Kevin Kho

01/19/2022, 3:58 PM
So you need to log-in because that creates the
auth.toml
file and then Prefect pulls it from there in this line
The
config
is set when you import Prefect
p

Paulo Benatto

01/19/2022, 4:00 PM
we could inject the token in the LocalAgent one day ... Thanks a lot Kevin for your help i will follow your advice
šŸ‘ 1
2 Views