Skip to content

Commit

Permalink
Adjust token expiry window to 40 seconds because of Azure (#392)
Browse files Browse the repository at this point in the history
## Changes

Align with databricks/databricks-sdk-go#617 and
databricks/databricks-sdk-js#63

## Tests
<!-- 
How is this tested? Please see the checklist below and also describe any
other relevant tests
-->

- [x] `make test` run locally
- [x] `make fmt` applied
- [ ] relevant integration tests applied

Signed-off-by: Serge Smertin <[email protected]>
  • Loading branch information
nfx authored Oct 10, 2023
1 parent 4fb5e38 commit 26e41fe
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion databricks/sdk/oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ class Token:
def expired(self):
if not self.expiry:
return False
potentially_expired = self.expiry - timedelta(seconds=10)
# Azure Databricks rejects tokens that expire in 30 seconds or less,
# so we refresh the token 40 seconds before it expires.
potentially_expired = self.expiry - timedelta(seconds=40)
now = datetime.now(tz=potentially_expired.tzinfo)
is_expired = potentially_expired < now
return is_expired
Expand Down

0 comments on commit 26e41fe

Please sign in to comment.