Erik Paasonen
07/31/2025, 4:13 PMprefect.exceptions.PrefectHTTPStatusError: Client error '401 Unauthorized' for url '<https://api.prefect.cloud/api/accounts>...
Marvin
07/31/2025, 4:14 PMMarvin
07/31/2025, 4:14 PMprefect cloud login
with your new API key
2. Long-Running Flow Issues
- If your flow runs for more than 24 hours, you might encounter authentication issues
- This is related to token expiration during long-running tasks
- Consider breaking up very long-running flows into smaller chunks
3. Environment/Configuration Issues
- Check if your PREFECT_API_KEY
environment variable is still set correctly
- Verify you're logged into the correct workspace with prefect cloud workspace ls
- Ensure you're using the correct profile with prefect profile ls
4. Version Compatibility
- If you've recently upgraded Prefect, ensure all components (client, server, workers) are on compatible versions
- Some users have reported auth issues when upgrading to newer versions
To resolve this, try the following steps:
1. First, verify your current authentication:
bash
prefect cloud workspace ls
2. If that fails, generate a new API key in the Prefect Cloud UI and login again:
bash
prefect cloud login -k 'your-new-api-key'
3. Verify your profile and workspace settings:
bash
prefect profile ls
prefect config view
If these steps don't resolve the issue, please let me know and provide:
- How long your flows typically run
- Whether you've recently upgraded Prefect
- The output of prefect version
This will help me provide more specific guidance for your situation.Erik Paasonen
07/31/2025, 4:30 PMMarvin
07/31/2025, 4:30 PMMarvin
07/31/2025, 4:30 PMBrendan Dalpe
07/31/2025, 4:38 PMresource "time_rotating" "ninety_days" {
rotation_days = 90
}
# Pass the time_rotating resource to the `api_key_expiration` attribute
# in order to automate the rotation of the Service Account key
resource "prefect_service_account" "example_rotate_time_key" {
name = "my-service-account"
api_key_expiration = time_rotating.ninety_days.rotation_rfc3339
}
Brendan Dalpe
07/31/2025, 4:40 PMErik Paasonen
07/31/2025, 4:40 PM