Hi guys I have a newbie question. I want to inject...
# prefect-server
p
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
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
Copy code
prefect.utilities.exceptions.AuthorizationError: No agent API token provided.
k
What Prefect version are you on?
p
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
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
we could inject the token in the LocalAgent one day ... Thanks a lot Kevin for your help i will follow your advice
šŸ‘ 1