Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
jFloury
New Member

Using msggraph sdk in Fabric notebooks

Hi !

I'm trying to use the msgraph sdk in Fabric notebook, but I'm facing an SSL issue.

 

 

import asyncio
import msal
from azure.identity.aio import ClientSecretCredential
from azure.identity import DeviceCodeCredential

client_secret="AAA"
client_id = "BBB"
tenant_id = "CCC"

credential = ClientSecretCredential(tenant_id,client_id,client_secret)
scopes = ['https://graph.microsoft.com/.default']

from msgraph import GraphServiceClient
client = GraphServiceClient(credentials=credential, scopes=scopes)

async def get_user():
    user = await client.users.by_user_id('myUPN').get()
    if user:
        print(user.display_name)

await get_user()

 

 

When I run this example code, I have the following issue :
 
ConnectError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1007)
 
Seems to be an error to the local certificate, of root used by the notebook.
I encountered this issue to another notebook and had to use the option verify=False on HTTP request, wich is unavaiable in the msgraph python SDK?
Thanks for any help
Jérôme
1 ACCEPTED SOLUTION
jFloury
New Member

Thank you for your answer.

 

The simpliest way is to add those 3 lines :

 

import certifi
import os
os.environ['SSL_CERT_FILE'] = certifi.where()

 

Jérôme

View solution in original post

2 REPLIES 2
jFloury
New Member

Thank you for your answer.

 

The simpliest way is to add those 3 lines :

 

import certifi
import os
os.environ['SSL_CERT_FILE'] = certifi.where()

 

Jérôme

V-yubandi-msft
Community Support
Community Support

Hi @jFloury ,

Thank you for joining us on the Microsoft Fabric Community Forum.

 

This error happens because Python can't verify the SSL certificate for the Microsoft Graph API. Basically, it can't find a valid root certificate in your local certificate store. This issue is quite common in custom or isolated environments that don't automatically install root certificates.

 

  • Ensure your notebook environment has the latest root certificates installed. You can do this by updating your environment, or by downloading and installing a new set of certificates. Make sure your system recognizes these new certificates.
  • For custom or missing certificates, specify a CA certificate file (such as ca-bundle.crt) for SSL verification.
  • Inspect Python’s default certificate path to check if any root certificates are missing.
  • If the SSL issue continues, try using a different authentication method, like Device Code Credential. This might help bypass the problem in certain environments
  • Utilize the MSGraph SDK functions to interact with the Microsoft Graph API within your notebook.

 

If my answer addressed your query, kindly mark it as the Accepted Solution to assist others.

I'd also be grateful for a 'Kudos' if you found my response useful!    

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.