@@ -19,8 +19,11 @@ public class TokenCredentialAuthProvider extends BaseAuthenticationProvider {
1919 private final TokenCredential tokenCredential ;
2020 /** Context options which can be optionally set by the user */
2121 private final TokenRequestContext context ;
22+ /** Custom hosts which can be optionally set by the user */
23+ private List <String > customHosts = null ;
2224 /** Default scope to use when no scopes are provided */
2325 private static final String DEFAULT_GRAPH_SCOPE = "https://graph.microsoft.com/.default" ;
26+
2427 /**
2528 * Creates an Authentication provider using a passed in TokenCredential
2629 *
@@ -45,14 +48,35 @@ public TokenCredentialAuthProvider(@Nonnull final List<String> scopes, @Nonnull
4548 this .tokenCredential = Objects .requireNonNull (tokenCredential , "tokenCredential parameter cannot be null." );
4649 }
4750
51+ /**
52+ * Creates an Authentication provider using a TokenCredential and a list of custom hosts
53+ * @param tokenCredential Credential object inheriting the TokenCredential interface used to instantiate the Auth Provider.
54+ * @param customHosts the user defined custom hosts.
55+ */
56+ public TokenCredentialAuthProvider (@ Nonnull final TokenCredential tokenCredential , @ Nonnull final List <String > customHosts ){
57+ this (Collections .singletonList (DEFAULT_GRAPH_SCOPE ), tokenCredential );
58+ this .customHosts = customHosts ;
59+ }
60+
61+ /**
62+ * Creates an Authentication provider using a TokenCredential, a list of scopes, and a list of custom hosts.
63+ * @param scopes Specified desired scopes of the Auth Provider
64+ * @param tokenCredential Credential object inheriting the TokenCredential interface used to instantiate the Auth Provider
65+ * @param customHosts the user defined custom hosts.
66+ */
67+ public TokenCredentialAuthProvider (@ Nonnull final List <String > scopes , @ Nonnull final TokenCredential tokenCredential , @ Nonnull final List <String > customHosts ) {
68+ this (scopes , tokenCredential );
69+ this .customHosts = customHosts ;
70+ }
71+
4872 /**
4973 * Returns an AccessToken as a string
5074 *
5175 * @return String representing the retrieved AccessToken
5276 */
5377 @ Nonnull
5478 public CompletableFuture <String > getAuthorizationTokenAsync (@ Nonnull final URL requestUrl ) {
55- if (shouldAuthenticateRequestWithUrl (Objects .requireNonNull (requestUrl , "requestUrl parameter cannot be null" )))
79+ if (shouldAuthenticateRequestWithUrl (Objects .requireNonNull (requestUrl , "requestUrl parameter cannot be null" ), customHosts ))
5680 return this .tokenCredential
5781 .getToken (this .context )
5882 .toFuture ()
0 commit comments