33import com .microsoft .graph .core .CoreConstants ;
44import com .microsoft .graph .core .requests .middleware .GraphTelemetryHandler ;
55import com .microsoft .graph .core .requests .options .GraphClientOption ;
6+ import com .microsoft .kiota .authentication .BaseBearerTokenAuthenticationProvider ;
67import com .microsoft .kiota .http .KiotaClientFactory ;
8+ import com .microsoft .kiota .http .middleware .AuthorizationHandler ;
79import com .microsoft .kiota .http .middleware .UrlReplaceHandler ;
810import com .microsoft .kiota .http .middleware .options .UrlReplaceHandlerOption ;
911import okhttp3 .Interceptor ;
@@ -37,6 +39,33 @@ public static OkHttpClient.Builder create() {
3739 public static OkHttpClient .Builder create (@ Nonnull Interceptor ... interceptors ) {
3840 return create (new GraphClientOption (), interceptors );
3941 }
42+
43+ /**
44+ * OkHttpClient Builder for Graph with specified Interceptors
45+ * @param interceptors desired interceptors for use in requests.
46+ * @return an OkHttpClient Builder instance.
47+ */
48+ @ Nonnull
49+ public static OkHttpClient .Builder create (@ Nonnull List <Interceptor > interceptors ) {
50+ return create (new GraphClientOption (), interceptors .toArray (new Interceptor [0 ]));
51+ }
52+
53+ /**
54+ * OkHttpClient Builder for Graph with specified AuthenticationProvider.
55+ * Adds an AuthorizationHandler to the OkHttpClient Builder.
56+ * @param authenticationProvider the AuthenticationProvider to use for requests.
57+ * @return an OkHttpClient Builder instance.
58+ */
59+ @ Nonnull
60+ public static OkHttpClient .Builder create (@ Nonnull BaseBearerTokenAuthenticationProvider authenticationProvider ) {
61+ GraphClientOption graphClientOption = new GraphClientOption ();
62+ Interceptor [] interceptors = createDefaultGraphInterceptors (graphClientOption );
63+ ArrayList <Interceptor > interceptorList = new ArrayList <>(Arrays .asList (interceptors ));
64+ interceptorList .add (new AuthorizationHandler (authenticationProvider ));
65+ graphClientOption .featureTracker .setFeatureUsage (FeatureFlag .AUTH_HANDLER_FLAG );
66+ return create (graphClientOption , interceptorList );
67+ }
68+
4069 /**
4170 * OkHttpClient Builder for Graph with specified Interceptors and GraphClientOption.
4271 *
@@ -60,6 +89,17 @@ public static OkHttpClient.Builder create(@Nonnull GraphClientOption graphClient
6089 }
6190 return builder ;
6291 }
92+
93+ /**
94+ * OkHttpClient Builder for Graph with specified Interceptors and GraphClientOption.
95+ * @param graphClientOption the GraphClientOption for use in requests.
96+ * @param interceptors desired interceptors for use in requests.
97+ * @return an OkHttpClient Builder instance.
98+ */
99+ public static OkHttpClient .Builder create (@ Nonnull GraphClientOption graphClientOption , @ Nonnull List <Interceptor > interceptors ) {
100+ return create (graphClientOption , interceptors .toArray (new Interceptor [0 ]));
101+ }
102+
63103 /**
64104 * The OkHttpClient Builder with optional GraphClientOption
65105 *
@@ -92,6 +132,5 @@ private static void addDefaultFeatureUsages(GraphClientOption graphClientOption)
92132 graphClientOption .featureTracker .setFeatureUsage (FeatureFlag .RETRY_HANDLER_FLAG );
93133 graphClientOption .featureTracker .setFeatureUsage (FeatureFlag .REDIRECT_HANDLER_FLAG );
94134 graphClientOption .featureTracker .setFeatureUsage (FeatureFlag .URL_REPLACEMENT_FLAG );
95- graphClientOption .featureTracker .setFeatureUsage (FeatureFlag .BATCH_REQUEST_FLAG );
96135 }
97136}
0 commit comments