Repository navigation
Commit 98d2712
Add JWT token support alongside API keys in GraphQLClient (#87)
## Summary
Enhances the `GraphQLClient` to support authentication using both API
keys and JWT tokens. The client now intelligently detects the token type
and applies the appropriate authorization header format, enabling
seamless integration with JWT-based authentication flows.
## Key Accomplishments
- **Dual authentication support**: The GraphQL client now accepts both
traditional API keys and JWT tokens for authentication
- **Automatic token type detection**: Implements logic to distinguish
between API keys and JWTs, applying the correct `Authorization` header
format (`Bearer` for JWTs vs. the existing mechanism for API keys)
- **Backward compatible**: Existing API key-based authentication
continues to work without any changes to consumer code
## Changes
- Modified `robosystems_client/graphql/client.py` to:
- Add JWT token detection and handling logic
- Set appropriate authorization headers based on the token type
- Maintain existing API key authentication as the default path
## Breaking Changes
None. This is a backward-compatible enhancement. Existing clients using
API keys will continue to function identically.
## Testing Notes
- Verify authentication works correctly when providing a valid JWT token
- Verify authentication continues to work correctly with existing API
keys
- Confirm that malformed or expired JWTs are handled gracefully and
surface appropriate error messages
- Test edge cases around token format detection to ensure API keys are
not misidentified as JWTs and vice versa
## Infrastructure Considerations
- Ensure that backend GraphQL endpoints are configured to accept both
API key and JWT-based authorization headers
- JWT token issuance and refresh mechanisms should be in place before
relying on JWT authentication in production environments
- Review any token expiration and renewal strategies, as JWTs typically
have shorter lifespans than API keys
---
🤖 Generated with [Claude Code](https://claude.ai/code)
**Branch Info:**
- Source: `chore/jwt-token-graphql-auth`
- Target: `main`
- Type: feature
Co-Authored-By: Claude <noreply@anthropic.com>1 file changed
Lines changed: 18 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
68 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
69 | 85 | | |
70 | 86 | | |
71 | 87 | | |
| |||
0 commit comments