โ06-19-2025 01:38 AM
I have a FastAPI Databricks App deployed to a hosted workspace. How can I call the API from external tools like Postman?
P.S. I was able to call the API within the same browser.
โ06-20-2025 02:40 AM
Hi @AndyK ,
External tools donโt share browserโs login context, so youโll need to add a bearer token in the Authorization header manually.
Start by generating an access token. You can either use the Databricks CLI (databricks auth token) to get an OAuth token, or create a Personal Access Token (PAT) from your workspace settings.
Then in Postman, enter your API endpoint like:
https://<workspace-host>/api/<endpoint-path>
Go to the Authorization tab, choose Bearer Token, and paste your token.
Make sure you have CAN USE permission on the Databricks App. Also, note that tokens,especially OAuth, can expire (usually in about an hour), so you might need to generate new one when needed
โ07-04-2025 06:22 PM
Hi,
PAT doesn't seem to work, but we use a workspace token and it was able to go through. Thanks
โ07-20-2025 08:35 AM
How to generate one?
โ07-20-2025 09:09 AM
I tried generating, the token this for service principle:
export CLIENT_ID=<client-id>
export CLIENT_SECRET=<client-secret>
curl --request POST \
--url <token-endpoint-URL> \
--user "$CLIENT_ID:$CLIENT_SECRET" \
--data 'grant_type=client_credentials&scope=all-apis'
It did generates a token, but that token still doesn't work with the Databricks App i created.
I am just passing it like:
response = requests.get(
"https://<app specific url>.azure.databricksapps.com/api/v1/table",
headers={"Authorization": f"Bearer {token} "})
print(response.json())
โ07-20-2025 08:33 AM
What do you mean by workspace token? Can you elaborate a little?
โ07-21-2025 01:39 AM
Hi,
Make sure your token endpoint url is like this: https://<databricks-instance>/oidc/v1/token.
Refer here for workspace-level access token: https://docs.databricks.com/aws/en/dev-tools/auth/oauth-m2m
Also make sure you have granted access of the service principal to the app: https://apps-cookbook.dev/docs/fastapi/getting_started/connections/connect_from_app
Passionate about hosting events and connecting people? Help us grow a vibrant local communityโsign up today to get started!
Sign Up Now