05-14-2024 07:11 AM
I am trying to generate PAT for a service principle.
I am following the documentation as shown below:
https://docs.databricks.com/en/dev-tools/auth/oauth-m2m.html#create-token-in-account
I have prepared the below curl command:
I am getting below error:
Please help me to create the curl command that can generate the PAT
05-19-2024 11:57 PM - edited 05-19-2024 11:58 PM
I was able to generate the workspace level token using the databricks cli.
I set the following details in the databricks cli profile(.databrickscfg) file:
host = https://myworksapce.azuredatabricks.net/
account_id = (my db account id)
client_id = (my sp client id)
client_secret = (generated from databricks worksapce)
After setting these, I ran the following command and generated the token:
databricks tokens create --lifetime-seconds 157680000
05-15-2024 06:30 AM
Hi @NarenderKumar, Here’s a general example of how you might use a curl
command to generate a Personal Access Token (PAT) for a service principal in Azure Databricks:
curl --location --request POST 'https://<databricks-workspace-url>/api/2.0/token/create' \
--header 'Authorization: Bearer <bearer-token>' \
--header 'Content-Type: application/json' \
--data-raw '{
"lifetime_seconds": <lifetime-in-seconds>,
"comment": "<comment>"
}'
In this command:
<databricks-workspace-url>
with your Databricks workspace URL.<bearer-token>
with your bearer token.<lifetime-in-seconds>
with the desired lifetime of the token in seconds.<comment>
with a comment that helps you identify this token in the future.Please note that this is a general example and you might need to adjust it based on your specific re...123.
Also, remember to store your generated PAT in a secure location and do not share it with others1. If you lose the PAT, you cannot regenerate the same token and you will need to create a new one1. If you believe that the token has been compromised, it is strongly recommended that you immediately ...1.
Let me know if you need further assistance! 😊
05-15-2024 06:43 AM
Hi @Kaniz_Fatma Thank you for the details.
1. The command that you have shared takes token in the header, but the command that I am trying to use is to generate the token for a service principle
2. The command shared by you is not taking a client id and client secret. so how can we generate it for a service principle
3. we can generated tokens at the account level and workspace level. The command shared by you is at workspace level not at the account level.
Please help me if you know how to generate PAT for a service principle at the account level.
05-19-2024 11:57 PM - edited 05-19-2024 11:58 PM
I was able to generate the workspace level token using the databricks cli.
I set the following details in the databricks cli profile(.databrickscfg) file:
host = https://myworksapce.azuredatabricks.net/
account_id = (my db account id)
client_id = (my sp client id)
client_secret = (generated from databricks worksapce)
After setting these, I ran the following command and generated the token:
databricks tokens create --lifetime-seconds 157680000
Excited to expand your horizons with us? Click here to Register and begin your journey to success!
Already a member? Login and join your local regional user group! If there isn’t one near you, fill out this form and we’ll create one for you to join!