danielcweeks commented on code in PR #13809: URL: https://github.com/apache/iceberg/pull/13809#discussion_r2276834097
########## core/src/main/java/org/apache/iceberg/rest/auth/OAuth2Util.java: ########## @@ -157,29 +157,33 @@ public static Map<String, String> buildOptionalParam( private static OAuthTokenResponse refreshToken( RESTClient client, + AuthConfig config, Map<String, String> headers, String subjectToken, String subjectTokenType, - String scope, - String oauth2ServerUri, Map<String, String> optionalOAuthParams) { - Map<String, String> request = - tokenExchangeRequest( - subjectToken, - subjectTokenType, - scope != null ? ImmutableList.of(scope) : ImmutableList.of(), - optionalOAuthParams); - - OAuthTokenResponse response = - client.postForm( - oauth2ServerUri, - request, - OAuthTokenResponse.class, - headers, - ErrorHandlers.oauthErrorHandler()); - response.validate(); + if (config.exchangeEnabled()) { + Map<String, String> request = + tokenExchangeRequest( + subjectToken, + subjectTokenType, + config.scope() != null ? ImmutableList.of(config.scope()) : ImmutableList.of(), + optionalOAuthParams); - return response; + OAuthTokenResponse response = + client.postForm( + config.oauth2ServerUri(), + request, + OAuthTokenResponse.class, + headers, + ErrorHandlers.oauthErrorHandler()); + response.validate(); + + return response; + } else { + return fetchToken( Review Comment: I'll add a check, but that's really a configuration issue since if you only have a token, then your only option is exchange flow. Disabling exchange and not having a client credential would also mean that you need to disable refresh (you won't be able to get a new token regardless). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org