Skip to content

Adding Databricks Azure tokens (Bearer token) support. (Issue #121)#122

Closed
divyavanmahajan wants to merge 1 commit into
databricks:mainfrom
divyavanmahajan:support_aad_token
Closed

Adding Databricks Azure tokens (Bearer token) support. (Issue #121)#122
divyavanmahajan wants to merge 1 commit into
databricks:mainfrom
divyavanmahajan:support_aad_token

Conversation

@divyavanmahajan
Copy link
Copy Markdown
Contributor

Issue #121 : Support Azure AD Tokens instead of PAT tokens

PAT vs Azure AD tokens - PAT tokens are workspace specific and usually have a long expiry. Azure AD tokens expire within a few hours and the same token will work across all workspaces with SSO enabled.

The NodeJS SQL driver was extended to support Azure AD tokens.

Description of change:

  • Introduces useAADToken in connection options.
  • When useAADToken=true, the PlainHTTPAuthentication class will send a Bearer authorization header with the Azure AD token, instead of the Basic authorization header when using a PAT token.
  • Unit tests extended for PlainHTTPAuthentication for Azure tokens.
  • E2E tests extended to support AAD Tokens

Workaround:
To use AAD token - you can tweak (@databricks/sql 1.1.1) as follows to use Azure AD tokens.

const { DBSQLClient, auth } = require('@databricks/sql');
// Patch to Databricks SQL driver to send Azure AD token as Bearer token.
Reflect.defineProperty(auth.PlainHttpAuthentication.prototype, 'getToken', {
  value: function () {
    return `Bearer ${this.password}`
  }
})

// Use normally - replacing token with your AAD token.

Submitted by:
Divya van Mahajan divyavanmahajan@users.noreply.github.com

@divyavanmahajan
Copy link
Copy Markdown
Contributor Author

Closed. Incorrect branch. Will resubmit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants