lishuxu commented on code in PR #1132:
URL: https://github.com/apache/iceberg-cpp/pull/1132#discussion_r4720338906
##########
src/iceberg/catalog/rest/auth/auth_session_internal.h:
##########
@@ -254,43 +254,85 @@ class OAuth2Session final : public AuthSession,
auto result = RetryRunner<retry::StopRetryOn<>>({.num_retries =
5}).Run([this] {
return RefreshToken();
});
+ if (!result.has_value()) {
+ // One final credential-backed attempt, within the same close guard.
+ result = RefreshToken(/*recover=*/true);
+ }
if (!result.has_value()) {
ICEBERG_LOG_WARN("Failed to refresh OAuth2 token: {}",
result.error().message);
MarkRefreshStopped();
return std::nullopt;
}
+ if (!result->has_value()) {
+ MarkRefreshStopped();
+ }
return *result;
}
- // Record that no further refresh will be scheduled after a failure.
+ // Record that no further refresh will be scheduled.
void MarkRefreshStopped() {
std::lock_guard lock(refresh_mutex_);
refresh_stopped_ = true;
}
- Result<std::optional<std::chrono::milliseconds>> RefreshToken() {
+ Result<OAuthTokenResponse> FetchRefreshToken(const std::string& token,
+ const std::string&
issued_token_type,
+ bool recover) {
+ auto empty_session = AuthSession::MakeDefault({});
+ if (!config_.exchange_enabled) {
+ return OAuth2Util::FetchToken(*client_, *empty_session,
refresh_properties_);
+ }
+ auto headers =
+ recover
+ ? std::unordered_map<std::string, std::string>{{"Authorization",
+ "Basic " +
+ Base64::Encode(
Review Comment:
The ID and secret are now form-encoded separately, then joined with : before
Base64 encoding. The tests cover a+b and secret-only credentials.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]