@@ -1008,6 +1008,11 @@ public static ApiClient getDefaultApiClient() {
10081008 secrets .put ("appKeyAuth" , appKeyAuth );
10091009 }
10101010 defaultApiClient .configureApiKeys (secrets );
1011+ // Configure bearerAuth authorization
1012+ String bearerAuthToken = System .getenv ("DD_BEARER_TOKEN" );
1013+ if (bearerAuthToken != null ) {
1014+ defaultApiClient .setBearerToken (bearerAuthToken );
1015+ }
10111016
10121017 return defaultApiClient ;
10131018 }
@@ -1068,6 +1073,14 @@ public ApiClient(Map<String, Authentication> authMap) {
10681073 } else {
10691074 authentications .put ("appKeyAuth" , new ApiKeyAuth ("header" , "DD-APPLICATION-KEY" ));
10701075 }
1076+ if (authMap != null ) {
1077+ auth = authMap .get ("bearerAuth" );
1078+ }
1079+ if (auth instanceof HttpBearerAuth ) {
1080+ authentications .put ("bearerAuth" , auth );
1081+ } else {
1082+ authentications .put ("bearerAuth" , new HttpBearerAuth ("bearer" ));
1083+ }
10711084 // Prevent the authentications from being modified.
10721085 authentications = Collections .unmodifiableMap (authentications );
10731086 }
@@ -2450,5 +2463,11 @@ protected void updateParamsForAuth(
24502463 }
24512464 auth .applyToParams (queryParams , headerParams , cookieParams , "" , "" , uri );
24522465 }
2466+ // Apply bearer token auth if configured (sent alongside any other auth headers).
2467+ Authentication bearerAuth = authentications .get ("bearerAuth" );
2468+ if (bearerAuth instanceof HttpBearerAuth
2469+ && ((HttpBearerAuth ) bearerAuth ).getBearerToken () != null ) {
2470+ bearerAuth .applyToParams (queryParams , headerParams , cookieParams , "" , "" , uri );
2471+ }
24532472 }
24542473}
0 commit comments