how can I access the prefect cloud graphql api usi...
# prefect-server
a
how can I access the prefect cloud graphql api using an api key? Do I somehow create a jwt token from the api key?
k
If you use the interactive API in the UI, it’s already authenticated. If using the Prefect Client Python object, it fetches whatever authentication is stored from
Copy code
prefect auth login --key <YOUR-KEY>
but if the key is not persisted, the Client can take in an API key
a
say i am creating a new UI and want to access the cloud api from the new UI
im looking at the network tab on my browser and it shows a bearer token
k
In Python code it would be:
Copy code
query = """query {flow{ name, id}}"""


url = '<https://api.prefect.io>'
r = <http://requests.post|requests.post>(url, json={'query': query}, headers={"authorization": "Bearer API_TOKEN"})
a
thanks @Kevin Kho your the man!