@@ -401,7 +401,7 @@ public SelfServiceProfilesEntity selfServiceProfiles() {
401401 */
402402 public static class Builder {
403403 private final String domain ;
404- private final String apiToken ;
404+ private TokenProvider tokenProvider
405405 private Auth0HttpClient httpClient = DefaultHttpClient .newBuilder ().build ();
406406
407407 /**
@@ -411,7 +411,7 @@ public static class Builder {
411411 */
412412 public Builder (String domain , String apiToken ) {
413413 this .domain = domain ;
414- this .apiToken = apiToken ;
414+ this .tokenProvider = SimpleTokenProvider . create ( apiToken ) ;
415415 }
416416
417417 /**
@@ -425,12 +425,22 @@ public Builder withHttpClient(Auth0HttpClient httpClient) {
425425 return this ;
426426 }
427427
428+ /**
429+ * Configure the token provider with an {@link TokenProvider}.
430+ * @param tokenProvider the API Token provider to use when making requests.
431+ * @return the builder instance.
432+ */
433+ public Builder withTokenProvider (TokenProvider tokenProvider ) {
434+ this .tokenProvider = tokenProvider ;
435+ return this ;
436+ }
437+
428438 /**
429439 * Build a {@link ManagementAPI} instance using this builder's configuration.
430440 * @return the configured {@code ManagementAPI} instance.
431441 */
432442 public ManagementAPI build () {
433- return new ManagementAPI (domain , SimpleTokenProvider . create ( apiToken ) , httpClient );
443+ return new ManagementAPI (domain , tokenProvider , httpClient );
434444 }
435445 }
436446}
0 commit comments