Search code examples
azureapache-sparkazure-databricks

Azure Databricks Cluster API Authentication


I have a spark cluster on Azure DataBricks and I am trying to access Cluster Information via this Rest API https://docs.azuredatabricks.net/api/latest/clusters.html#get.

However, I am unable to figure out the correct way of using the personal token to authenticate.

Here are the possible combinations that I have tried and their result

  1. Encoding the personal token in base 64 format "Token:[personal token]"

enter image description here

  1. Using the personal token as it is enter image description here

  2. Using token id available from User Settings Screen

enter image description here

In all the cases, I am getting 401 Error. Can someone please help in finding the correct way of using the token?


Solution

  • Token that you get is Bearer token so it would be as

    Authorization: Bearer <token_here>
    

    And with CURL

    curl 'https://<databricks-instance>/api/2.0/clusters/get?cluster_id=<id>' -X GET -H "Authorization: Bearer <personal-access-token-value>"
    

    There is no need for encoding or anything. It's already encoded.