Hi there! I'm running into an issue with api authe...
# ask-community
e
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
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
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
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
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
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
It says
(from env)
-- I cleared the old keys from
env
but now if I check env it's listed again
r
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
Success! Thank you so much!
❤️ 1
r
Glad to hear it worked for you! 🙂