feat: add constructor to set clientId on Client creation #776
+25
−0
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