@@ -54,14 +54,8 @@ public class AuthApi {
5454 private final Consumer <HttpResponse <InputStream >> memberVarResponseInterceptor ;
5555 private final Consumer <HttpResponse <String >> memberVarAsyncResponseInterceptor ;
5656
57- // Per-API Bearer authentication
58- private String bearerToken ;
59-
60- // Per-API Basic authentication
61- private String username ;
62- private String password ;
63-
64-
57+ // Custom headers to be sent with every request from this API client
58+ private final Map <String , String > extraHeaders = new java .util .HashMap <>();
6559
6660 public AuthApi () {
6761 this (Configuration .getDefaultApiClient ());
@@ -78,59 +72,26 @@ public AuthApi(ApiClient apiClient) {
7872 }
7973
8074 /**
81- * Helper method to set access token for Bearer authentication.
82- * @param bearerToken Bearer token
83- * @return AuthApi
75+ * Add a custom header to be sent with every request from this API client.
76+ * @param name Header name
77+ * @param value Header value
78+ * @return this
8479 */
85- public AuthApi setBearerToken (String bearerToken ) {
86- this .bearerToken = bearerToken ;
80+ public AuthApi addHeader (String name , String value ) {
81+ this .extraHeaders . put ( name , value ) ;
8782 return this ;
8883 }
8984
9085 /**
91- * Helper method to set username for HTTP basic authentication .
92- * @param username Username
93- * @return AuthApi
86+ * Remove a custom header .
87+ * @param name Header name
88+ * @return this
9489 */
95- public AuthApi setUsername (String username ) {
96- this .username = username ;
90+ public AuthApi removeHeader (String name ) {
91+ this .extraHeaders . remove ( name ) ;
9792 return this ;
9893 }
9994
100- /**
101- * Helper method to set password for HTTP basic authentication.
102- * @param password Password
103- * @return AuthApi
104- */
105- public AuthApi setPassword (String password ) {
106- this .password = password ;
107- return this ;
108- }
109-
110-
111-
112- /**
113- * Apply authentication settings directly to request headers.
114- * This avoids modifying the shared ApiClient's authentication state.
115- */
116- private void applyAuthToHeaders (HttpRequest .Builder localVarRequestBuilder ) {
117- if (bearerToken != null ) {
118- localVarRequestBuilder .header ("Authorization" , "Bearer " + bearerToken );
119- }
120- if (username != null && password != null ) {
121- String credentials = java .util .Base64 .getEncoder ().encodeToString ((username + ":" + password ).getBytes ());
122- localVarRequestBuilder .header ("Authorization" , "Basic " + credentials );
123- }
124- }
125-
126- /**
127- * Apply authentication settings directly to query parameters.
128- * This avoids modifying the shared ApiClient's authentication state.
129- */
130- private String applyAuthToQueryParams (String queryString ) {
131- return queryString ;
132- }
133-
13495
13596 protected ApiException getApiException (String operationId , HttpResponse <InputStream > response ) throws IOException {
13697 String body = response .body () == null ? null : new String (response .body ().readAllBytes ());
@@ -205,7 +166,7 @@ private HttpRequest.Builder testAuthHttpBasicRequestBuilder() throws ApiExceptio
205166
206167 String localVarPath = "/auth/http/basic" ;
207168
208- String authQuery = applyAuthToQueryParams ( null );
169+ String authQuery = null ; // No longer need to apply auth to query params
209170 if (authQuery != null && !authQuery .isEmpty ()) {
210171 localVarRequestBuilder .uri (URI .create (memberVarBaseUri + localVarPath + '?' + authQuery ));
211172 } else {
@@ -218,8 +179,10 @@ private HttpRequest.Builder testAuthHttpBasicRequestBuilder() throws ApiExceptio
218179 if (memberVarReadTimeout != null ) {
219180 localVarRequestBuilder .timeout (memberVarReadTimeout );
220181 }
221- // Apply per-API authentication directly to the request
222- applyAuthToHeaders (localVarRequestBuilder );
182+ // Add custom headers
183+ for (Map .Entry <String , String > entry : extraHeaders .entrySet ()) {
184+ localVarRequestBuilder .header (entry .getKey (), entry .getValue ());
185+ }
223186 if (memberVarInterceptor != null ) {
224187 memberVarInterceptor .accept (localVarRequestBuilder );
225188 }
@@ -286,7 +249,7 @@ private HttpRequest.Builder testAuthHttpBearerRequestBuilder() throws ApiExcepti
286249
287250 String localVarPath = "/auth/http/bearer" ;
288251
289- String authQuery = applyAuthToQueryParams ( null );
252+ String authQuery = null ; // No longer need to apply auth to query params
290253 if (authQuery != null && !authQuery .isEmpty ()) {
291254 localVarRequestBuilder .uri (URI .create (memberVarBaseUri + localVarPath + '?' + authQuery ));
292255 } else {
@@ -299,8 +262,10 @@ private HttpRequest.Builder testAuthHttpBearerRequestBuilder() throws ApiExcepti
299262 if (memberVarReadTimeout != null ) {
300263 localVarRequestBuilder .timeout (memberVarReadTimeout );
301264 }
302- // Apply per-API authentication directly to the request
303- applyAuthToHeaders (localVarRequestBuilder );
265+ // Add custom headers
266+ for (Map .Entry <String , String > entry : extraHeaders .entrySet ()) {
267+ localVarRequestBuilder .header (entry .getKey (), entry .getValue ());
268+ }
304269 if (memberVarInterceptor != null ) {
305270 memberVarInterceptor .accept (localVarRequestBuilder );
306271 }
0 commit comments