
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
ms-python-client
Advanced tools
Microsoft graph API Python client with support for Device Flow Oauth tokens with deleguated access.
This package is available on Pypi
pip install ms-python-client
Define the following variables in your env or your .env file:
For testing purposes, you can use the following value:
This token could be obtained from the Microsoft Graph Explorer by clicking on the Sign in with Microsoft button and then clicking on the Access Token tab.
from ms_python_client import MSApiClient
ms_client = MSApiClient.init_from_env()
from ms_python_client import MSApiClient
ms_client = MSApiClient.init_from_dotenv()
from ms_python_client import MSApiClient, Config
config = Config(
azure_authority="<YOUR AZURE AUTHORITY>",
azure_client_id="<YOUR AZURE CLIENT ID>",
azure_scope="<YOUR AZURE SCOPE>" # Ex. [User.Read, Calendars.ReadWrite, etc.]
)
ms_client = MSApiClient(
config=config,
)
By default the token is stored in a file called token_cache.bin in the current directory. You can change this behavior by passing the token_cache_file parameter to the Config constructor.
from ms_python_client import MSApiClient, Config
config = Config(
azure_authority="<YOUR AZURE AUTHORITY>",
azure_client_id="<YOUR AZURE CLIENT ID>",
azure_scope="<YOUR AZURE SCOPE>", # Ex. [User.Read, Calendars.ReadWrite, etc.]
token_cache_file="/path/to/token_cache.bin"
)
ms_client = MSApiClient(
config=config,
)
This will allow you to reuse the token in the next executions of your script and even in different scripts.
USER_ID = "12345"
SUBJECT = "Test meeting"
query = {"$count": "true", "$filter": f"contains(subject,'{SUBJECT}')"}
result = cern_ms_client.events.list_events(USER_ID, query)
from ms_python_client import setup_logs
setup_logs(log_level=logging.DEBUG)
Instead of using the MSApiClient class, you can use the CERNMSApiClient class, which is a subclass of the MSApiClient class.
This class will provide you some more utilities but it will only work for CERN users (obviously).
This will be used in the context of synchronizing the events between the CERN Indico system and the calendars of the Zoom Rooms.
Follow the How to configure the client variables to make API calls section and then:
from ms_python_client import CERNMSApiClient
cern_ms_client = CERNMSApiClient.init_from_dotenv()
You will find useful the EventParameters and PartialEventParameters classes, which will help you to create the events.
The EventParameters class is used to create an event, while the PartialEventParameters class is used to update an event.
ZOOM_ID is the id of the zoom meeting, which can be found inside the url of a meeting link. This is mandatory to create an event.USER_ID is the email of the Zoom Room.from ms_python_client import CERNMSApiClient, EventParameters, PartialEventParameters
cern_ms_client = CERNMSApiClient.init_from_dotenv()
USER_ID = os.getenv("USER_ID") # Which is the email of the Zoom Room
ZOOM_ID = os.getenv("ZOOM_ID")
event_parameters = EventParameters(
subject="Test meeting",
start_time="2021-10-01T12:00:00",
end_time="2021-10-01T13:00:00",
timezone="Europe/Zurich",
zoom_url="https://cern.zoom.us/******",
)
partial_event_parameters = PartialEventParameters(
end_time="2021-10-01T14:00:00",
) # You can update only the end_time of the event for example
cern_ms_client.events.create_event(USER_ID, ZOOM_ID, event_parameters)
cern_ms_client.events.update_event_by_zoom_id(USER_ID, ZOOM_ID, partial_event_parameters)
cern_ms_client.events.delete_event_by_zoom_id(USER_ID, ZOOM_ID)
FAQs
This package is used to interact with the microsoft graph API
We found that ms-python-client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.