Chris Bui
01/08/2024, 9:50 PMMarvin
01/08/2024, 9:50 PMPREFECT_API_KEY
environment variable or configure it in your flow script to use Prefect Cloud. The service account's name isn't typically necessary for interacting with the API, but if you want to display it, you might need to use Prefect's GraphQL API to query the details of your service account, which goes beyond the excerpts provided.
For more specific details, you would need to consult the Prefect GraphQL API documentation or possibly use the Prefect Python client inside your scripts to interact with the API. If you can provide more context, or if you need to see how to authenticate and use the Prefect Cloud API, please let me know, and I'll do my best to assist you further.Nate
01/08/2024, 11:35 PMChris Bui
01/08/2024, 11:36 PMNate
01/08/2024, 11:42 PM» curl -s -H "Authorization: Bearer $PREFECT_API_KEY" "<https://api.prefect.cloud/api/me/>" | jq
{
"id": "<uuid>",
"handle": "stoat",
"first_name": "Nathan",
"last_name": "Nowack",
"email": "<mailto:nate@prefect.io|nate@prefect.io>",
"personal_account_id": "<uuid>",
"settings": {
"default_timezone": "America/Chicago",
"default_color_palette": "protanomaly",
"tutorial_completed": true,
"feature_previews": []
}
}
Nate
01/08/2024, 11:46 PM» ipython
In [1]: from prefect.client.cloud import get_cloud_client
In [2]: from prefect.settings import PREFECT_CLOUD_API_URL
In [3]: async with get_cloud_client() as client:
...: print((await client._client.get(f"{PREFECT_CLOUD_API_URL.value()}/me")).json())
...:
{'id': '<uuid>', 'handle': 'stoat', 'first_name': 'Nathan', 'last_name': 'Nowack', 'email': 'nate@prefect.io', 'personal_account_id': '<uuid>', 'settings': {'default_timezone': 'America/Chicago', 'default_color_palette': 'protanomaly', 'tutorial_completed': True, 'feature_previews': []}}
Chris Bui
01/08/2024, 11:50 PMNate
01/08/2024, 11:58 PMChris Bui
01/09/2024, 4:09 AMFile "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1786, in get
return await self.request(
File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1559, in request
return await self.send(request, auth=auth, follow_redirects=follow_redirects)
File "/usr/local/lib/python3.9/site-packages/prefect/client/base.py", line 312, in send
response.raise_for_status()
File "/usr/local/lib/python3.9/site-packages/prefect/client/base.py", line 164, in raise_for_status
raise PrefectHTTPStatusError.from_httpx_error(exc) from exc.__cause__
prefect.exceptions.PrefectHTTPStatusError: Client error '403 Forbidden' for url '<https://api.prefect.cloud/api/me/>'
Response: {'detail': 'Only users (not service accounts) can access this endpoint.'}
Can you help us here?Nate
01/09/2024, 5:14 AMChris Bui
01/09/2024, 5:12 PMcreated_by.display_value
and updated_by.display_value
which happen to be the service account name. Is there a way to get this value without having to first create an object in Prefect cloud?Chris Bui
01/11/2024, 5:45 PMNate
01/11/2024, 5:46 PMNate
01/11/2024, 5:46 PMChris Bui
01/11/2024, 5:47 PM