<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Databricks model serving endpoint returns 403 Unauthorized access to workspace when using servic in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/databricks-model-serving-endpoint-returns-403-unauthorized/m-p/133299#M49787</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/187797"&gt;@ashfire&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;It seems that your service principal is getting a an access token at Account level, but model serving endpoints live at the workspace level. In databricks you have 2 separate API:&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Account level API&lt;/P&gt;&lt;P&gt;- Workspace Level&lt;/P&gt;&lt;P&gt;As you can see at below screen - the serving endpoint lives at workspace level so it expects access token generated at that level.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="szymon_dybczak_0-1759181873614.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/20299i5EABA83376871B98/image-size/medium?v=v2&amp;amp;px=400" role="button" title="szymon_dybczak_0-1759181873614.png" alt="szymon_dybczak_0-1759181873614.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Here you can read more details about the difference between those two and how to generate workspace level access token&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://learn.microsoft.com/en-us/azure/databricks/dev-tools/auth/#account-level-apis-and-workspace-level-apis" target="_blank" rel="noopener"&gt;Authorizing access to Azure Databricks resources - Azure Databricks | Microsoft Learn&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 29 Sep 2025 21:42:01 GMT</pubDate>
    <dc:creator>szymon_dybczak</dc:creator>
    <dc:date>2025-09-29T21:42:01Z</dc:date>
    <item>
      <title>Databricks model serving endpoint returns 403 Unauthorized access to workspace when using service</title>
      <link>https://community.databricks.com/t5/data-engineering/databricks-model-serving-endpoint-returns-403-unauthorized/m-p/133294#M49785</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I deployed a simple Iris model in Databricks Model Serving and exposed it as an endpoint. I’m trying to query the endpoint using a service principal.&amp;nbsp;I can successfully fetch the access token with the following&amp;nbsp;databricks_token()&amp;nbsp;function:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def databricks_token(): 
    token_url = f"https://accounts.cloud.databricks.com/oidc/accounts/{MY_ACCOUNT_ID}/v1/token"
    scope = "all-apis"

    data = {
        "grant_type": "client_credentials",
        "client_id": CLIENT_ID,
        "client_secret": CLIENT_SECRET,
        "scope": scope,
    }

    response = requests.post(token_url, data=data)
    token_data = response.json()
    access_token = token_data["access_token"]
    return access_token&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;Then I try to query the endpoint using&amp;nbsp;score_model():&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def score_model():
    url = f"https://{WORKSPACE_HOST}.cloud.databricks.com/serving-endpoints/{MODEL_SERVING_ENDPOINT_NAME}/invocations"
    headers = {'Authorization': f'Bearer {databricks_token()}', 'Content-Type': 'application/json'}
    data_json = json.dumps(data, allow_nan=True)
    response = requests.request(method='POST', headers=headers, url=url, data=data_json)
    if response.status_code != 200:
        raise Exception(f'Request failed with status {response.status_code}, {response.text}')
    return response.json()

print(score_model())&lt;/LI-CODE&gt;&lt;P&gt;But the call fails with:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Exception: Request failed with status 403, {"error_code":"403","message":"Unauthorized access to workspace: xxxxxxxxxx"}&lt;/P&gt;&lt;P&gt;In the Databricks UI, the serving endpoint already has the permission “All workspace users can query”.&lt;/P&gt;&lt;P&gt;What am I missing to allow a service principal to query the model serving endpoint? Do I need to assign additional workspace or service principal permissions beyond the endpoint-level access?&lt;BR /&gt;Note that the route optimization is not enabled here.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Sep 2025 20:14:51 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/databricks-model-serving-endpoint-returns-403-unauthorized/m-p/133294#M49785</guid>
      <dc:creator>ashfire</dc:creator>
      <dc:date>2025-09-29T20:14:51Z</dc:date>
    </item>
    <item>
      <title>Re: Databricks model serving endpoint returns 403 Unauthorized access to workspace when using servic</title>
      <link>https://community.databricks.com/t5/data-engineering/databricks-model-serving-endpoint-returns-403-unauthorized/m-p/133299#M49787</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/187797"&gt;@ashfire&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;It seems that your service principal is getting a an access token at Account level, but model serving endpoints live at the workspace level. In databricks you have 2 separate API:&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Account level API&lt;/P&gt;&lt;P&gt;- Workspace Level&lt;/P&gt;&lt;P&gt;As you can see at below screen - the serving endpoint lives at workspace level so it expects access token generated at that level.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="szymon_dybczak_0-1759181873614.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/20299i5EABA83376871B98/image-size/medium?v=v2&amp;amp;px=400" role="button" title="szymon_dybczak_0-1759181873614.png" alt="szymon_dybczak_0-1759181873614.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Here you can read more details about the difference between those two and how to generate workspace level access token&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://learn.microsoft.com/en-us/azure/databricks/dev-tools/auth/#account-level-apis-and-workspace-level-apis" target="_blank" rel="noopener"&gt;Authorizing access to Azure Databricks resources - Azure Databricks | Microsoft Learn&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Sep 2025 21:42:01 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/databricks-model-serving-endpoint-returns-403-unauthorized/m-p/133299#M49787</guid>
      <dc:creator>szymon_dybczak</dc:creator>
      <dc:date>2025-09-29T21:42:01Z</dc:date>
    </item>
    <item>
      <title>Re: Databricks model serving endpoint returns 403 Unauthorized access to workspace when using servic</title>
      <link>https://community.databricks.com/t5/data-engineering/databricks-model-serving-endpoint-returns-403-unauthorized/m-p/133300#M49788</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/110502"&gt;@szymon_dybczak&lt;/a&gt;, Thanks for your comment.&lt;BR /&gt;One of the admins in this workspace tried using the token generated via client id and secret, and were able to successfully get a response from the serving endpoint using this same above mentioned code.&lt;BR /&gt;&lt;BR /&gt;Could this be related to specific permissions required for regular users? I would really appreciate it if you could elaborate or share an example to help resolve this issue. Thanks again for your help and guidance.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Sep 2025 22:12:37 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/databricks-model-serving-endpoint-returns-403-unauthorized/m-p/133300#M49788</guid>
      <dc:creator>ashfire</dc:creator>
      <dc:date>2025-09-29T22:12:37Z</dc:date>
    </item>
    <item>
      <title>Re: Databricks model serving endpoint returns 403 Unauthorized access to workspace when using servic</title>
      <link>https://community.databricks.com/t5/data-engineering/databricks-model-serving-endpoint-returns-403-unauthorized/m-p/133309#M49794</link>
      <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/187797"&gt;@ashfire&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;After second read of documentation I think the endpoint you choose should work (with scope="all-apis"). According to docs it will let you call both REST API , so sorry for confusion in previous message.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="szymon_dybczak_0-1759212714168.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/20300i0358AD7D02F8D66C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="szymon_dybczak_0-1759212714168.png" alt="szymon_dybczak_0-1759212714168.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The reason it works out of the box for workspace administrator is because workspace admin has all necessary permission in workspace.&amp;nbsp;&lt;BR /&gt;But for any other user I think you need to grant them explicitly. Could you check if your Service Principal has appropriate permission on your model serving endpoint?&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://docs.databricks.com/aws/en/machine-learning/model-serving/manage-serving-endpoints#manage-permissions-on-your-model-serving-endpoint" target="_blank" rel="noopener"&gt;Manage model serving endpoints | Databricks on AWS&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Also, please check if your Service Principal has been added to the workspace:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="szymon_dybczak_1-1759213034708.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/20301i078325F17EA9EA37/image-size/medium?v=v2&amp;amp;px=400" role="button" title="szymon_dybczak_1-1759213034708.png" alt="szymon_dybczak_1-1759213034708.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;And lastly, check if he has workspace access entitelment enabled:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="szymon_dybczak_2-1759213087395.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/20302i8B874E95C820136F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="szymon_dybczak_2-1759213087395.png" alt="szymon_dybczak_2-1759213087395.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Sep 2025 06:18:52 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/databricks-model-serving-endpoint-returns-403-unauthorized/m-p/133309#M49794</guid>
      <dc:creator>szymon_dybczak</dc:creator>
      <dc:date>2025-09-30T06:18:52Z</dc:date>
    </item>
  </channel>
</rss>

