Microsoft graph API wrapper for Microsoft Graph written in Python.
pip install microsoftgraph-python
If you need an office 365 token, send office365 attribute in True like this:
from microsoftgraph.client import Client
client = Client('CLIENT_ID', 'CLIENT_SECRET', account_type='by defect common', office365=True)
If you don't, just instance the library like this:
from microsoftgraph.client import Client
client = Client('CLIENT_ID', 'CLIENT_SECRET', account_type='by defect common')
url = client.authorization_url(redirect_uri, scope, state=None)
token = client.exchange_code(redirect_uri, code)
token = client.refresh_token(redirect_uri, refresh_token)
token = client.set_token(token)
me = client.get_me()
me = client.get_message(message_id="")
Webhook section, see the api documentation: https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/resources/webhooks
subscription = client.create_subscription(change_type, notification_url, resource, expiration_datetime, client_state=None)
renew = client.renew_subscription(subscription_id, expiration_datetime)
renew = client.delete_subscription(subscription_id)
Onenote section, see the api documentation: https://developer.microsoft.com/en-us/graph/docs/concepts/integrate_with_onenote
notebooks = client.list_notebooks()
notebook = client.get_notebook(notebook_id)
section_notebook = client.get_notebook_sections(notebook_id)
add_page = client.create_page(section_id, files)
pages = client.list_pages()
Calendar section, see the api documentation: https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/resources/calendar
events = client.get_me_events()
events = client.create_calendar_event(subject, content, start_datetime, start_timezone, end_datetime, end_timezone,
recurrence_type, recurrence_interval, recurrence_days_of_week, recurrence_range_type,
recurrence_range_startdate, recurrence_range_enddate, location, attendees, calendar=None)
events = client.get_me_calendars()
events = client.create_calendar(name)
Contacts section, see the api documentation: https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/resources/contact
If you need a specific contact send the contact id in data_id
specific_contact = client.outlook_get_me_contacts(data_id="")
If you want all the contacts
specific_contact = client.outlook_get_me_contacts()
add_contact = client.outlook_create_me_contact()
add_contact_folder = client.outlook_create_contact_in_folder(folder_id)
folders = client.outlook_get_contact_folders()
add_folders = client.outlook_create_contact_folder()
Onedrive section, see the api documentation: https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/resources/onedrive
root_items = client.drive_root_items()
root_children_items = client.drive_root_children_items()
folder_items = client.drive_specific_folder(folder_id)
Excel section, see the api documentation: https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/resources/excel
For use excel, you should know the folder id where the file is
create_session = client.drive_create_session(item_id)
refresh_session = client.drive_refresh_session(item_id)
close_session = client.drive_close_session(item_id)
get_worksheets = client.excel_get_worksheets(item_id)
specific_worksheet = client.excel_get_specific_worksheet(item_id, worksheet_id)
add_worksheet = client.excel_add_worksheet(item_id)
update_worksheet = client.excel_update_worksheet(item_id, worksheet_id)
get_charts = client.excel_get_charts(item_id, worksheet_id)
add_chart = client.excel_add_chart(item_id, worksheet_id)
get_tables = client.excel_get_tables(item_id)
add_table = client.excel_add_table(item_id)
add_column = client.excel_add_column(item_id, worksheets_id, table_id)
add_row = client.excel_add_row(item_id, worksheets_id, table_id)
get_rows = client.excel_get_rows(item_id, table_id)
get_range = client.excel_get_range(item_id, worksheets_id)
update_range = client.excel_update_range(item_id, worksheets_id)
- requests
test/test.py