databricks / dbt-databricks

A dbt adapter for Databricks.
https://databricks.com
Apache License 2.0
214 stars 115 forks source link

Debug logging for expired SPA and store refresh token #699

Closed thijs-nijhuis closed 3 months ago

thijs-nijhuis commented 3 months ago

Resolves #640

Description

When using an Azure App Registration with a 'Single-page Application' authentication platform as the oAuth endpoint, the token will always expire after 24h. It is not possible to fetch a new token after this and a new consent (and external browser login) is required. This is 'by design' and should therefore not yield warning in the terminal hinting on a possible problem. Instead, writing to the debugger should suffice. The second issue this PR tackles is that, after a token expires and a new refresh token is requested from the endpoint, that new token is never stored. This causes the authentication logic to request a new refresh token for every dbt command after initial token has expired (valid for 1h) where it is only needed after it is expired.

Checklist

benc-db commented 3 months ago

Re-pushing to run integration tests.

Can you run

tox -e linter

to see what you need to fix linting issue?

thijs-nijhuis commented 3 months ago

@benc-db , sorry about that. Forgot about the linter. I ran it and it fixed a couple of things. I also changed the code slightly to check if the token has changed after it is checked to be valid. Only when changed, it will store the new token using keyring

benc-db commented 3 months ago

Going to open a new PR of this to update the changelog and then merge. Thanks for the contribution!

benc-db commented 3 months ago

Closed in favor of 700.