adutra commented on code in PR #12555:
URL: https://github.com/apache/iceberg/pull/12555#discussion_r2013717006


##########
core/src/main/java/org/apache/iceberg/rest/auth/OAuth2Manager.java:
##########
@@ -64,18 +65,89 @@ public class OAuth2Manager extends RefreshingAuthManager {
   private AuthSessionCache sessionCache;
 
   public OAuth2Manager(String managerName) {
-    super(managerName + "-token-refresh");
+    super(managerName);
     this.name = managerName;
   }
 
   @Override
+  public OAuth2Manager withClient(RESTClient restClient) {
+    Preconditions.checkNotNull(restClient, "invalid restClient: null");
+    refreshClient = restClient.withAuthSession(AuthSession.EMPTY);
+    return this;
+  }
+
+  @Override
+  public OAuth2Util.AuthSession authSession(AuthScope scope) {
+    Preconditions.checkNotNull(scope, "invalid scope: null");
+    Preconditions.checkState(
+        refreshClient != null, "cannot create AuthSession: no RESTClient 
available");
+    if (sessionCache == null) {
+      sessionCache = newSessionCache(name, scope.properties());
+    }
+    AuthConfig config = AuthConfig.fromProperties(scope.properties());
+    keepRefreshed(config.keepRefreshed());
+    if (scope instanceof AuthScopes.Initial) {
+      warnIfDeprecatedTokenEndpointUsed(scope.properties());
+      return initSession(config);
+    } else if (scope instanceof AuthScopes.Catalog) {
+      return catalogSession(config);
+    } else if (scope instanceof AuthScopes.Contextual) {
+      return contextualSession((AuthScopes.Contextual) scope);
+    } else if (scope instanceof AuthScopes.Table) {
+      return tableSession((AuthScopes.Table) scope);
+    } else {
+      return genericSession(scope, config);
+    }
+  }
+
+  /**
+   * @deprecated since 1.9.0, will be removed in 1.10.0; use {@link 
#authSession(AuthScope)}
+   *     instead.
+   */
+  @Override
+  @Deprecated
+  @SuppressWarnings("deprecation")
   public OAuth2Util.AuthSession initSession(RESTClient initClient, Map<String, 
String> properties) {
-    warnIfDeprecatedTokenEndpointUsed(properties);
-    AuthConfig config =
-        ImmutableAuthConfig.builder()
-            .from(AuthConfig.fromProperties(properties))
-            .keepRefreshed(false) // no token refresh during init
-            .build();
+    return 
withClient(initClient).authSession(ImmutableAuthScopes.Initial.of(properties));
+  }
+
+  /**
+   * @deprecated since 1.9.0, will be removed in 1.10.0; use {@link 
#authSession(AuthScope)}
+   *     instead.
+   */
+  @Override
+  @Deprecated
+  @SuppressWarnings("deprecation")
+  public OAuth2Util.AuthSession catalogSession(

Review Comment:
   If I remove the methods here I get many revapi error like this:
   
   ```
   java.method.returnTypeChanged: The return type changed from 
'org.apache.iceberg.rest.auth.OAuth2Util.AuthSession' to  
'org.apache.iceberg.rest.auth.AuthSession'.
     
     old: method org.apache.iceberg.rest.auth.OAuth2Util.AuthSession 
org.apache.iceberg.rest.auth.OAuth2Manager::catalogSession(org.apache.iceberg.rest.RESTClient,
 java.util.Map<java.lang.String, java.lang.String>)
     new: method org.apache.iceberg.rest.auth.AuthSession 
org.apache.iceberg.rest.auth.AuthManager::catalogSession(org.apache.iceberg.rest.RESTClient,
 java.util.Map<java.lang.String, java.lang.String>) @ 
org.apache.iceberg.rest.auth.OAuth2Manager
   ```



-- 
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

Reply via email to