[PECO-909] Automatically renew oauth token when refresh token is available #156
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PECO-909
It is possible to auto-renew oauth access token if corresponding refresh token was provided. However, due to some limitations in library architecture, it wasn't possible to use that mechanism: after
DBSQLClient.connect()
call credentials were cached and not updated until re-connected. In this PR the following changes are suggestsed:HiveDriver
should not cache thrift client object and obtain it before running each operation. This allows to provide a new client if needed;thrift
library does not provide any API to just update client options,DBSQLClient
will re-create thrift client (and connection) when needed. Turns out that this is safe and almost does not add much overhead (especially considering that token refresh does not happen very often).HttpConnection
and moved toDBSQLClient
soDBSQLClient
can detect credentials changeHiveDriver
needs a client instance,DBSQLClient
will request auth credentials, and if they have changed (e.g. oauth access token expired and was refreshed) - it will create a new thrift client.DatabricksOAuth
stores token on its own. The existing persistence mechanism was utilized for this purpose.This is quite a big change, but library's public interface and observed behavior won't change.
Probably review will be easier commit by commit.