cancel
Showing results for 
Search instead for 
Did you mean: 
Administration & Architecture
Explore discussions on Databricks administration, deployment strategies, and architectural best practices. Connect with administrators and architects to optimize your Databricks environment for performance, scalability, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 

OAuth API for service user

andreapeterson
New Contributor II

Is there a way to programmatically create an OAuth secret for for a workspace service principal via API/SDK? As of now, the only way I can see doing this is through UI

2 ACCEPTED SOLUTIONS

Accepted Solutions

Shua42
Databricks Employee
Databricks Employee

Hi @andreapeterson ,

Currently, there isn't support for creating OAuth secrets through the API, only through the UI in the admin console. You can create 'on behalf of' tokens through the API for service principals, but not an OAuth secret at the moment: https://docs.databricks.com/api/workspace/tokenmanagement/createobotoken 

View solution in original post

vr
Contributor II

@andreapeterson isn't it the API you are looking for?
https://docs.databricks.com/api/azure/account/serviceprincipalsecrets/create

It is an account-level API, but, counterintuitively, when we create service principals in the workspace, they propagate into account behind the scene! If you create an account-level SP right away, it will not be added into any workspace, but can be added later using workspace-level create method. It is pretty confusing, because when we do that in the UI, these details are hidden from us. At least this is how it works in my Azure environment. It took me a while to realize that.

To summarize, in your case you need to try to create OAuth secret using the account-level API I gave, even though you created it in the workspace. Hopefully you have permissions to call account API in your org.

View solution in original post

4 REPLIES 4

Shua42
Databricks Employee
Databricks Employee

Hi @andreapeterson ,

Currently, there isn't support for creating OAuth secrets through the API, only through the UI in the admin console. You can create 'on behalf of' tokens through the API for service principals, but not an OAuth secret at the moment: https://docs.databricks.com/api/workspace/tokenmanagement/createobotoken 

Hi Shua,
Thanks for responding. What is the difference between a token and OAuth? I only see OAuth in UI. 
Also, is adding OAuth secrets for a service principal via api on the road map for Databricks?

vr
Contributor II

@andreapeterson isn't it the API you are looking for?
https://docs.databricks.com/api/azure/account/serviceprincipalsecrets/create

It is an account-level API, but, counterintuitively, when we create service principals in the workspace, they propagate into account behind the scene! If you create an account-level SP right away, it will not be added into any workspace, but can be added later using workspace-level create method. It is pretty confusing, because when we do that in the UI, these details are hidden from us. At least this is how it works in my Azure environment. It took me a while to realize that.

To summarize, in your case you need to try to create OAuth secret using the account-level API I gave, even though you created it in the workspace. Hopefully you have permissions to call account API in your org.

andreapeterson
New Contributor II

This was exactly it! I do have permissions to call account api's in my org, however I did not realize I could call that api to make oauth secrets for other various workspace principals, so thank you so much for helping me and finding this and explaining that, it is confusing the propagation behind the scenes but I think I am finally getting the hang of it haha. Thank you again this was a great find

Join Us as a Local Community Builder!

Passionate about hosting events and connecting people? Help us grow a vibrant local community—sign up today to get started!

Sign Up Now
OSZAR »