Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredJoin us at FabCon Vienna from September 15-18, 2025, for the ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM. Get registered
I'm trying to query to down all the notebooks' names in my current workspace. I'm using an entra id api to make the query that has the workspace.read.all permission and is added as admin to my workspace. I still get <Response [403]>. I get the access token successfully.
import json
import requests
import msal
from azure.identity import ClientSecretCredential
from azure.keyvault.secrets import SecretClient
import requests
# Fetch the credentials using the service principal
v_tenant_id = notebookutils.credentials.getSecret(p_keyvault_url, p_secret_name_tenant)
v_client_id = notebookutils.credentials.getSecret(p_keyvault_url, p_secret_name_client)
v_client_secret = notebookutils.credentials.getSecret(p_keyvault_url, p_secret_name_secret)
# Create a credential using the service principal
v_credential = ClientSecretCredential(v_tenant_id, v_client_id, v_client_secret)
# Initialize SecretClient with Key Vault URL and the credentials
v_client = SecretClient(vault_url=p_keyvault_url, credential=v_credential)
token_url = f"https://login.microsoftonline.com/{v_tenant_id}/oauth2/v2.0/token"
token_data = {
'grant_type': 'client_credentials',
'client_id': v_client_id,
'client_secret': v_client_secret,
'scope': 'https://api.fabric.microsoft.com/.default'
}
token_r = requests.post(token_url, data=token_data)
access_token = token_r.json().get("access_token")
workspaceID = '*****'
api_url = f'https://api.fabric.microsoft.com/v1/workspaces/{workspaceID}/notebooks'
headers = {
"Authorization": access_token,
"Content-Type": "application/json"
}
res = requests.get(api_url,headers=headers)
note = res.json().get("value",[])
for note in note:
if note['type'] == 'Notebook':
print(note['displayName'])
Solved! Go to Solution.
Hi @dobosdavid ,
Thank you for reaching out to Microsoft Fabric Community.
Thank you @dobosdavid and @yvaubourg for the response.
First, in Azure Active Directory, navigate to App registrations and select your application. Under the API permissions section, add the necessary Application permission. Specifically, add Workspace.Read.All, Notebook.Read.All, and optionally Capacity.Read.All. After adding these permissions, be sure to click Grant admin consent to enable the app to use them.
Next, in the Power BI Admin Portal (https://app.powerbi.com/admin-portal ) , Under Tenant settings,
If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it!
Thank you!!
Hi @dobosdavid ,
I hope the information provided is helpful. Feel free to reach out if you have any further questions or would like to discuss this in more detail. If responses provided answers your question, please accept it as a solution so other community members with similar problems can find a solution faster.
Thank you!!
Hi @dobosdavid ,
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If the responses has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank you!!
Hi @dobosdavid ,
May I ask if the provided solution helped in resolving the issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.
Thank you!!
Hi @dobosdavid ,
Thank you for reaching out to Microsoft Fabric Community.
Thank you @dobosdavid and @yvaubourg for the response.
First, in Azure Active Directory, navigate to App registrations and select your application. Under the API permissions section, add the necessary Application permission. Specifically, add Workspace.Read.All, Notebook.Read.All, and optionally Capacity.Read.All. After adding these permissions, be sure to click Grant admin consent to enable the app to use them.
Next, in the Power BI Admin Portal (https://app.powerbi.com/admin-portal ) , Under Tenant settings,
If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it!
Thank you!!
Hi @dobosdavid,
To request the Fabric API with a microsoft entra identity, you have to allow this in the tenant settings.
See the MS documentation here.
A best pratctice is to use a Security Group that is allowing you to manage exactly wich Entre Identity can use the MS Fabric API.
Hope this would help.
Hi, thank you for the tip.
I followed the guide and put the service principal in a security group and then allowed the security group to use fabric apis. It does not say anything else. My problem still stays.
Hi @dobosdavid ,
Can you try using powerbi rest api to get the token? Im using the below code from notebook to fetch all notebooks under a workspace
For ex.,
Step 1: Using the below code to fetch token
Thank you for the tip, unfortunately this didn't solve my issue.