feat: add constructor to set clientId on Client creation#776
Closed
adenix wants to merge 1 commit intoauth0:masterfrom
Closed
feat: add constructor to set clientId on Client creation#776adenix wants to merge 1 commit intoauth0:masterfrom
adenix wants to merge 1 commit intoauth0:masterfrom
Conversation
Add new constructor Client(String name, String clientId) to allow setting the immutable clientId field during object construction. The existing Client(String name) constructor remains unchanged to maintain backward compatibility. This allows users to optionally set the clientId at construction time when needed, while the field remains immutable (no setter exists). - Add Client(String name, String clientId) constructor with JavaDoc - Add test for backward compatibility (existing constructor) - Add test for new constructor functionality - All existing tests continue to pass
f063b0b to
aebe732
Compare
Contributor
Author
|
This adds support for #778 |
tanya732
approved these changes
Oct 17, 2025
Contributor
|
LGTM !! |
This was referenced Oct 22, 2025
Closed
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
This PR adds a new constructor to the
Clientclass that allows setting theclientIdat construction time.Problem:
The Auth0 Management API allows users to specify a custom
client_idwhen creating a new client. However, the current SDK does not provide a way to set this value without using reflection, forcing users to write code like this:Solution:
This PR provides a clean, type-safe way to set the
clientIdduring construction without requiring reflection.Classes and methods added:
Client(String name, String clientId)constructor with JavaDocSummary of usage:
The
clientIdfield remains immutable as intended - there is no setter method, and it can only be set during object construction using the new constructor. The existing single-parameter constructor remains unchanged and continues to work as before for complete backward compatibility.References
client_idfield is documented as: "The id of the client. If not provided, it will be auto-generated."Testing
This change has been tested with comprehensive unit tests covering both the new functionality and backward compatibility:
shouldCreateClientWithNameOnly()to verify backward compatibilityshouldCreateClientWithNameAndClientId()to verify the new constructor sets both fields correctly./gradlew test --tests ClientTestTest coverage includes:
Checklist