Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
13,498 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I am using Ubuntu and Python 3.10 to authenticate using the O365 library. When attempting to download a file from SharePoint, I encounter the following SSL error:
SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: authority and subject key identifier mismatch (_ssl.c:1007)')
Relevant Code Snippet:
from azure.identity import DefaultAzureCredential
from azure.keyvault.secrets import SecretClient
from O365 import Account, MSGraphProtocol, FileSystemTokenBackend
import certifi
# Set up the Key Vault name and URI
# Use DefaultAzureCredential for authentication
# Retrieve Client ID and Client Secret from Key Vault
# Set up the O365 credentials using the values retrieved from Key Vault
azure_app_credentials = (client_id, client_secret)
# Set up the protocol and token backend
protocol = MSGraphProtocol(api_version='v1.0')
token = FileSystemTokenBackend(token_path='token', token_filename='o365_token.txt')
scopes = [
'Calendars.Read',
'Calendars.ReadWrite',
'Chat.Read',
'Chat.ReadWrite',
'Contacts.Read',
'Contacts.Read.Shared',
'Contacts.ReadWrite',
'Contacts.ReadWrite.Shared',
'email',
'Files.Read',
'Files.Read.All',
'Files.ReadWrite',
'Files.ReadWrite.All',
'Mail.Read',
'Mail.Read.Shared',
'Mail.ReadBasic.Shared',
'Mail.ReadWrite',
'Mail.ReadWrite.Shared',
'Mail.Send',
'Mail.Send.Shared',
'MailboxSettings.Read',
'MailboxSettings.ReadWrite',
'offline_access',
'openid',
'profile',
'Sites.Read.All',
'Sites.ReadWrite.All',
'User.Read'
]
# Authenticate with O365
account = Account(credentials=azure_app_credentials,
protocol=protocol,
token_backend=token,
scopes=scopes,
verify_ssl=True,
verify_ssl_cert=certifi.where())
if not account.is_authenticated:
account.authenticate(requested_scopes=scopes)
Thank you for help!