Skip to content

Conversation

@maoxiaowang
Copy link
Contributor

Fix SDK authentication to return consistent error responses.

Previously, missing or invalid API keys returned HTTP 200 with inconsistent messages and codes, making it impossible for SDK clients to detect authentication failures reliably.

What problem does this PR solve?

  • Optimize token_required decorator to preserve tenant_id injection.
  • token_required now raises Unauthorized exception for missing or invalid API keys.
  • Handle Unauthorized exceptions via app.errorhandler, returning code and HTTP 401.
  • Frontend can handle both HTTP 401 or code 401 responses and redirect to the login page.

Frontend Impact

  • Frontend now properly handles HTTP 401 responses.
  • No changes to existing pages or authentication logic.

Type of change

  • Performance Improvement

…so update frontend to redirect to login on HTTP 401
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. 🐞 bug Something isn't working, pull request that fix bug. labels Jan 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant