https://prefect.io logo
Title
e

Emma Keil-Vine

02/24/2023, 7:24 PM
Hi there! I'm running into an issue with api authentication. I've sucessfully logged in through my terminal, pasting my API key when prompted but when I try to run a flow locally I get the following error:
Cannot create flow run. Failed to reach API at <https://api.prefect.cloud/api/accounts/a9c0f124-ca06-4646-a501-57a405ebf3c7/workspaces/43f1b8a7-ed9c-46d2-a88a-55eef95b8ef7/>.
-- does anyone have any recommendations? TIA!
r

Ryan Peden

02/24/2023, 8:54 PM
I think encountered this in the past when I accidentally missed one character when copying and pasting the key. One thing you could try is running
prefect cloud login
and choosing browser-based login.
e

Emma Keil-Vine

02/24/2023, 8:56 PM
When I try browser login it just times out, no additional window/tab is ever opened
I've tried pasting the key a couple times, and made a new one but still with no luck
Additionally if I try to access a list of workspaces (
prefect cloud worksplace ls
) I get
Unable to authenticate. Please ensure your credentials are correct.
-- is there anyway to check what credentials it's referencing?
r

Ryan Peden

02/24/2023, 9:01 PM
prefect config view --show-secrets
should show you what it is trying to use.
Credentials in this case would just be your API URL and API key. Running the above CLI command will at least help you verify the settings are correct. If they look correct I'll try to find more info about what's causing this error for you.
e

Emma Keil-Vine

02/24/2023, 9:05 PM
Hmm no so the prefect key being listed is an old one from prefect 1 (starts with
pcu
) -- so something is overriding the key I use to login?
r

Ryan Peden

02/24/2023, 9:07 PM
Hmm, yeah - that would do it. Does it say
(from profile)
after the API key?
You could try creating a new profile by running
prefect profile create cloud
, then
prefect profile use cloud
. Then, run the settings command to see if the key is still getting overridden. If not, logging in with your new API key should work. If you don't mind getting rid of all your old settings and starting fresh, running
rm -rf ~/.prefect
should also solve the problem, but you'd lose saved settings and flow run history stored there.
e

Emma Keil-Vine

02/24/2023, 9:11 PM
It says
(from env)
-- I cleared the old keys from
env
but now if I check env it's listed again
r

Ryan Peden

02/24/2023, 9:14 PM
If you run
unset PREFECT_API_KEY
, does that get rid of it? Since it seems to be added to your environment variables automatically, I wonder if it is getting set in
.bashrc
or
.zshrc
or something similar? Or if you're on Windows and it's saved in your system env variables, it would get re-added any time you open a new terminal.
e

Emma Keil-Vine

02/24/2023, 9:31 PM
Success! Thank you so much!
❤️ 1
r

Ryan Peden

02/24/2023, 10:27 PM
Glad to hear it worked for you! 🙂