https://prefect.io logo
m

Michael Z

06/27/2023, 4:25 PM
hey for some reason when calling the prefect cloud api I get authenticated but not authorized. Just following this: https://docs.prefect.io/2.10.17/api-ref/rest-api/. For example I can call api/me but not flow_runs/filter even though the account id and workspace id are correct. Maye its an issue where the key has to be given permission to the workspace but I didnt see anywhere to do that in the UI. Anyone have this issue?
b

Bianca Hoch

06/27/2023, 5:39 PM
Hey Michael, it may be worth checking to see if the API key you'er using is valid. Can you try going through the steps in this article to check?
m

Michael Z

06/27/2023, 7:41 PM
@Bianca Hoch I just created a new api key, same issue. It seems like the api key authenticates fine, otherwise I wouldn't be able to use it for endpoints where workspace id and account id are not required. I get 403 Unauthorized for /health. Both workspace id and account id are uuid's correct? Maybe I need to add myself to the workspace? This is the free version by the way not sure if thats matters. Thanks.
a

Ajay

07/17/2023, 7:43 AM
@Bianca Hoch I am having the same issue curl -i -H ‘Authorization: Bearer xxxxx’ https://api.prefect.cloud/api/account/XXXXXX/workspace/XXXXXX/health I tried my own api key and service accounts api key and found that i am having the same issue. {"detail": "Unauthorized"}%
b

Bianca Hoch

07/17/2023, 6:26 PM
^ Ajay, could you try adjusting the url with this? I believe that it needs to be accounts and workspaces, plural. Maybe that'll make the difference.
curl -i -H 'Authorization: Bearer <api key here>' <https://api.prefect.cloud/api/accounts/><account>/workspaces/<workspace>/health
Also, for the account ID, make sure it matches what you see in the URL when you're navigating around your workspace in the UI
Another thing worth checking is whether or not you have set the
PREFECT_API_URL
or
PREFECT_API_KEY
in your environmental variables (with Linux you can type
printenv
to check). If you do, and they're different than what you have saved to your prefect profile (
prefect profile inspect
), that may cause some conflicts when calling the api