brettwooldridge / HikariCP

光 HikariCP・A solid, high-performance, JDBC connection pool at last.
Apache License 2.0
19.63k stars 2.9k forks source link

How to handle OAuth connections that require manually updating the token #2175

Open aiguofer opened 4 months ago

aiguofer commented 4 months ago

We currently have a server that maintains a connection pool to various DataWarehouses and we want to enable OAuth connections for Snowflake, but I'm struggling to figure out how to make it work with HikariCP.

Snowflake access tokens last for 10 minutes, and we'll have an external client that handles the OAuth flow and passes the Access Token back to the server when making requests. This client will handle token refreshes, so when the access token changes it'll simply pass along the new access token for subsequent requests. Here's some docs on the general flow: https://community.snowflake.com/s/article/HOW-TO-OAUTH-TOKEN-GENERATION-USING-SNOWFLAKE-CUSTOM-OAUTH

My initial thought is that I can:

Would this be enough to force Hikari to pick up the changed property when re-creating a connection? Is there some other recommended alternative?