1) My goal:
Connect Retool to a FastAPI backend using JWT Bearer token authentication to display a human review queue dashboard. The API requires:
Initial authentication via API key to get JWT tokens
Use JWT tokens in Authorization header to access protected endpoints
Display queue data in Retool tables and components
2) Issue:
REST API queries in Retool return 401 "Could not validate credentials" errors, despite the authentication working correctly:
Authentication succeeds: Token generation endpoint returns valid JWT tokens
REST API queries fail: All queries using Retool's REST API resource get 401 errors
JavaScript queries work: The exact same API calls work perfectly using JavaScript fetch()
External tools work: curl requests with the same token succeed
Error pattern:
API Response: 401 Unauthorized - {"detail": "Could not validate credentials"}
Retool Internal: POST /api/pages/uuids/[uuid]/query?queryName=getQueue 400 (Bad Request)
3) Steps I've taken to troubleshoot:
API Verification:
Confirmed API endpoints are accessible and healthy
Verified JWT tokens are valid (decoded and checked expiration)
Tested with curl using identical headers - works perfectly
CORS properly configured (requests pass preflight checks)
Retool Configuration Attempts:
Created fresh REST API resource with minimal configuration
Tested different Authorization header formats:
Bearer {{ token }}
{{ "Bearer " + token }}
Direct token value insertion
Removed all optional headers to isolate the issue
Verified token is correctly stored in Retool state variables
Workaround Success:
JavaScript queries using fetch() work flawlessly:
javascriptconst response = await fetch('https://api.domain.com/api/v1/review/queue', {
headers: {
'Authorization': Bearer ${token}
,
'Content-Type': 'application/json'
}
});
// Returns 200 OK with correct data
4) Additional info:
Retool Environment: Cloud (retool.com)
API Framework: FastAPI with standard OAuth2PasswordBearer
Authentication Flow: API Key → JWT Token → Bearer Authorization
What Works: JavaScript queries, curl, Postman
What Fails: Only Retool's REST API resource queries
Key Observation: The issue appears to be with how Retool's REST API resource handles/sends the Authorization header, as identical requests work through every other method tested.
The data available showing:
- Successful token generation
- Failed REST API query with 401 error
- Successful JavaScript query with same token
- Network tab showing request headers (Authorization sanitized by Retool)
Looking for guidance on whether this is a known issue with REST API resources and Bearer tokens, and if JavaScript queries are an acceptable long-term solution.