databricks / databricks-sdk-py

Databricks SDK for Python (Beta)
https://databricks-sdk-py.readthedocs.io/
Apache License 2.0
318 stars 103 forks source link

Using Azure App Registration with 'Mobile and desktop applications' fails refresh because of Origin header #671

Open thijs-nijhuis opened 1 month ago

thijs-nijhuis commented 1 month ago

Description We have an App Registration on Azure which used the 'Mobile and desktop applications' platform authentication. Getting a new token using the authorization code flows works as expected. But when a refresh of the token is needed, it fails with the following error

AADSTS9002326: Cross-origin token redemption is permitted only for the 'Single-Page Application' client-type. Request origin: 'http://localhost:8020'.

I think this is caused by the fact that the header is always set. Also for non-spa app registrations.

When getting a new token from scratch, a try/except strategy is used to make it work for both spa and non-spa platform. I think this would work here as well and also be more consistent.

Reproduction I use dbt-databricks in which I encountered this error. Therefor, I do not have any stand alone code.

Expected behavior Be able to refresh token for both SPA and 'Mobile and desktop applications' platforms.

Is it a regression? I don't think so.

Debug Logs N.A.

Other Information

Additional context I will try to solve and test this and create a PR linking to this issue.

thijs-nijhuis commented 1 week ago

Hi, can anyone please comment on this issue and perhaps trigger the test on the corresponding PR?