@@ -54,6 +54,15 @@ 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+
65+
5766 public AuthApi () {
5867 this (Configuration .getDefaultApiClient ());
5968 }
@@ -68,6 +77,61 @@ public AuthApi(ApiClient apiClient) {
6877 memberVarAsyncResponseInterceptor = apiClient .getAsyncResponseInterceptor ();
6978 }
7079
80+ /**
81+ * Helper method to set access token for Bearer authentication.
82+ * @param bearerToken Bearer token
83+ * @return AuthApi
84+ */
85+ public AuthApi setBearerToken (String bearerToken ) {
86+ this .bearerToken = bearerToken ;
87+ return this ;
88+ }
89+
90+ /**
91+ * Helper method to set username for HTTP basic authentication.
92+ * @param username Username
93+ * @return AuthApi
94+ */
95+ public AuthApi setUsername (String username ) {
96+ this .username = username ;
97+ return this ;
98+ }
99+
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+
134+
71135 protected ApiException getApiException (String operationId , HttpResponse <InputStream > response ) throws IOException {
72136 String body = response .body () == null ? null : new String (response .body ().readAllBytes ());
73137 String message = formatExceptionMessage (operationId , response .statusCode (), body );
@@ -141,14 +205,21 @@ private HttpRequest.Builder testAuthHttpBasicRequestBuilder() throws ApiExceptio
141205
142206 String localVarPath = "/auth/http/basic" ;
143207
144- localVarRequestBuilder .uri (URI .create (memberVarBaseUri + localVarPath ));
208+ String authQuery = applyAuthToQueryParams (null );
209+ if (authQuery != null && !authQuery .isEmpty ()) {
210+ localVarRequestBuilder .uri (URI .create (memberVarBaseUri + localVarPath + '?' + authQuery ));
211+ } else {
212+ localVarRequestBuilder .uri (URI .create (memberVarBaseUri + localVarPath ));
213+ }
145214
146215 localVarRequestBuilder .header ("Accept" , "text/plain" );
147216
148217 localVarRequestBuilder .method ("POST" , HttpRequest .BodyPublishers .noBody ());
149218 if (memberVarReadTimeout != null ) {
150219 localVarRequestBuilder .timeout (memberVarReadTimeout );
151220 }
221+ // Apply per-API authentication directly to the request
222+ applyAuthToHeaders (localVarRequestBuilder );
152223 if (memberVarInterceptor != null ) {
153224 memberVarInterceptor .accept (localVarRequestBuilder );
154225 }
@@ -215,14 +286,21 @@ private HttpRequest.Builder testAuthHttpBearerRequestBuilder() throws ApiExcepti
215286
216287 String localVarPath = "/auth/http/bearer" ;
217288
218- localVarRequestBuilder .uri (URI .create (memberVarBaseUri + localVarPath ));
289+ String authQuery = applyAuthToQueryParams (null );
290+ if (authQuery != null && !authQuery .isEmpty ()) {
291+ localVarRequestBuilder .uri (URI .create (memberVarBaseUri + localVarPath + '?' + authQuery ));
292+ } else {
293+ localVarRequestBuilder .uri (URI .create (memberVarBaseUri + localVarPath ));
294+ }
219295
220296 localVarRequestBuilder .header ("Accept" , "text/plain" );
221297
222298 localVarRequestBuilder .method ("POST" , HttpRequest .BodyPublishers .noBody ());
223299 if (memberVarReadTimeout != null ) {
224300 localVarRequestBuilder .timeout (memberVarReadTimeout );
225301 }
302+ // Apply per-API authentication directly to the request
303+ applyAuthToHeaders (localVarRequestBuilder );
226304 if (memberVarInterceptor != null ) {
227305 memberVarInterceptor .accept (localVarRequestBuilder );
228306 }
0 commit comments