Repository navigation
Add optional payload parameter to updateToken method for custom token refresh parameters #42368
meenakshi-ojha
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
🎯 Problem Statement
Currently, the Keycloak JavaScript adapter's
updateToken()method only allows refreshing tokens with the standard OAuth2 refresh token flow parameters. However, there are enterprise scenarios where additional custom parameters need to be sent during token refresh requests to accommodate:This limitation forces organizations to maintain custom forks of the Keycloak JavaScript adapter, increasing maintenance overhead and preventing adoption of new official releases.
💡 Proposed Solution
Enhance the
updateToken()method signature to accept an optionalpayloadparameter that allows sending additional custom parameters with the token refresh request.Current Signature:
Proposed Signature:
🔧 Implementation Details
The implementation would:
payloadparameter is optional, so existing code continues to work unchangedExample Usage:
🏢 Real-World Use Cases
1. Multi-tenant SaaS Applications
2. Compliance and Audit Requirements
3. Mobile/Native App Context
4. Enterprise SSO Integration
🌍 Impact on Community
Current Pain Points:
Benefits of This Enhancement:
✅ Benefits
🛠️ Implementation Reference
I have a working implementation that demonstrates this functionality and maintains 100% backward compatibility. The implementation has been tested in production environments.
Key Implementation Points:
Core Implementation:
TypeScript Definitions:
📊 Technical Analysis
Backward Compatibility: ✅ 100% - No breaking changes
Performance Impact: ✅ Minimal - Only processes payload when provided
Security: ✅ Safe - Validates input and follows OAuth2 standards
Testing: ✅ Comprehensive - Covers all scenarios including edge cases
🔄 Alignment with Keycloak Roadmap
This enhancement aligns with Keycloak's goals of:
❓ Questions for Community Discussion
Scope and Naming: Is
payloadthe right parameter name, or wouldadditionalParams/customParamsbe clearer?Parameter Validation: Should there be restrictions on parameter names (e.g., preventing override of standard OAuth2 params like
grant_type)?Value Types: Should we support only string values, or also numbers/booleans with automatic conversion?
Documentation: What examples and use cases should be highlighted in the official documentation?
Enterprise Features: Are there other similar enhancements that would benefit enterprise users?
🎯 Proposed Next Steps
If this proposal receives positive community feedback, I am prepared to:
📈 Expected Outcomes
Short Term:
Long Term:
This enhancement would eliminate the need for organizations to maintain custom forks, reducing maintenance overhead and improving adoption of official Keycloak releases while maintaining 100% backward compatibility.
About the Contributor
I work with enterprise Keycloak deployments and have hands-on experience with the challenges this enhancement addresses. The proposed solution has been tested in production environments and addresses real-world enterprise requirements.
All reactions