[ 
https://issues.apache.org/jira/browse/DRILL-8148?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17498776#comment-17498776
 ] 

ASF GitHub Bot commented on DRILL-8148:
---------------------------------------

jnturton commented on a change in pull request #2473:
URL: https://github.com/apache/drill/pull/2473#discussion_r815689882



##########
File path: 
exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/StorageResources.java
##########
@@ -200,6 +202,100 @@ public Response enablePlugin(@PathParam("name") String 
name, @PathParam("val") B
     }
   }
 
+  @POST
+  @Path("/storage/{name}/update_refresh_token")
+  @Produces(MediaType.APPLICATION_JSON)
+  public Response updateRefreshToken(@PathParam("name") String name,
+                                    @FormParam("refresh_token") String 
refreshToken) {
+    try {
+      if (storage.getPlugin(name).getConfig() instanceof 
AbstractSecuredStoragePluginConfig) {
+        DrillbitContext context = ((AbstractStoragePlugin) 
storage.getPlugin(name)).getContext();
+        OAuthTokenProvider tokenProvider = context.getoAuthTokenProvider();
+        PersistentTokenTable tokenTable = 
tokenProvider.getOauthTokenRegistry().getTokenTable(name);
+
+        // Set the access token
+        tokenTable.setRefreshToken(refreshToken);
+
+        return Response.status(Status.OK)
+          .entity("Refresh token have been updated.")
+          .build();
+      } else {
+        logger.error("{} is not a HTTP plugin. You can only add access tokens 
to HTTP plugins.", name);
+        return Response.status(Status.INTERNAL_SERVER_ERROR)
+          .entity(message("Unable to add tokens: %s", name))
+          .build();
+      }
+    } catch (PluginException e) {
+      logger.error("Error when adding tokens to {}", name);
+      return Response.status(Status.INTERNAL_SERVER_ERROR)
+        .entity(message("Unable to add tokens: %s", e.getMessage()))
+        .build();
+    }
+  }

Review comment:
       ```suggestion
     }
     
   ```




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


> Add REST Endpoints to Update OAuth Tokens
> -----------------------------------------
>
>                 Key: DRILL-8148
>                 URL: https://issues.apache.org/jira/browse/DRILL-8148
>             Project: Apache Drill
>          Issue Type: Improvement
>    Affects Versions: 1.20.0
>            Reporter: Charles Givre
>            Assignee: Charles Givre
>            Priority: Major
>             Fix For: Future
>
>
> See attached PR



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to