Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi,
I need to call Fabric APIs from notebook to get workspace, items and create shortcuts but getting following error just for shortcut creation.
'errorCode': 'InsufficientScopes', 'message': 'The caller does not have sufficient scopes to perform this operation'
The notebook owner is SPN as it is deployed through fabric ci-cd python library.
I tried following scopes but nothing worked for shortcut creation.
token_string = mssparkutils.credentials.getToken("pbi")
Similarly getting error while retrieving connections /v1/connections.
I noticed if I explicitly get token through ClientSecretCredential class and it worked fine to create shortcuts.
Thanks,
Gayatri
Solved! Go to Solution.
Hi @g3kuser ,
Hi @g3kuser ,
Thank you for reaching out to Microsoft Fabric Community Forum.
Since the notebook is being executed under a Service Principal (SPN), you'll need to ensure the app registration in Azure AD is correctly configured for the required permissions.
--Register the SPN (app) in Azure Active Directory, and assign the necessary API permissions for Microsoft Fabric.
--Recommended application-level permissions:
Tenant.Read.All
Workspace.ReadWrite.All
Shortcut.Create.All (if available)
--If you’re using the client credentials flow, you can also work with the /.default scope to inherit all granted permissions.
--After adding the permissions, make sure an Azure AD Admin grants admin consent to them.
Then, you can authenticate using the ClientSecretCredential as follows:
scope = 'https://api.fabric.microsoft.com/.default'
credential = ClientSecretCredential(tenant_id=tenant_id, client_id=client_id, client_secret=client_secret)
access_token = credential.get_token(scope)
token_string = access_token.token
This approach ensures that your Service Principal has the correct permissions to perform operations like creating shortcuts or managing connections through the Fabric APIs.
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!
Regards,
B Manikanteswara Reddy
My app is granted correct permission and I can make the calls successul by explicitly initializing credential object but it fails when only for few endpoints when I don't initialize and get token through mssparkutils.
token_string = mssparkutils.credentials.getToken("pbi")
Hi @g3kuser ,
Thanks for the confirmation. I have done the same with additional email regex check. Just in case in future the getUserName method ends up returning application name in case of SPN as executing user.
Thanks,
Gayatri