Skip to main content

A Pythonic interface to Microsoft's Graph API

Project description

msgraph2

This is a small(-ish) Python library for wrapping interactions with Microsoft's Graph API, specifically with respect to populating and interrogating SharePoint sites safely.

Why msgraph2? Because PyPi.org doesn't allow the package name msgraph because it is too similar to other (unspecified) packages also on the index. It was okay with msgraph2, however...

Examples

import msgraph2

sp = msgraph2.SafeSharePoint(
  host='yours.sharepoint.com',
  site='SITE-NAME',
  library='A Document Library',
  token=msgraph2.file_token('path/to/token.json')
)

sp.mkdir("/Incoming/Uploaded Documents", make_parents=True)

Where /path/to/token.json looks something like this:

{
  "access_token": "... your access token ..."
}

The msgraph2.file_token function causes the token to be re-read from the file every time it is needed. Other keys in the token JSON file will be explicitly ignored, so if you have a system of refreshing access tokens that rewrites the on-disk file every refresh, everything Just Works(TM).

If you are running a copy of Oauth-Taker, you can point msgraph2 there with the msgraph2.oauth_taker_token() helper instead:

import msgraph2

sp = msgraph2.SafeSharePoint(
  host='yours.sharepoint.com',
  site='SITE-NAME',
  library='A Document Library',
  token=msgraph2.oauth_taker_token(
    endpoint='https://ot.example.com/t/handler/t0',
    shared_key='my-sekrit-key-for-getting-tokens'
  )
)

sp.mkdir("/Incoming/Uploaded Documents", make_parents=True)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

msgraph2-0.4-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file msgraph2-0.4-py3-none-any.whl.

File metadata

  • Download URL: msgraph2-0.4-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.6 importlib-metadata/6.11.0 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.31.0 rfc3986/1.5.0 tqdm/4.66.2 urllib3/1.26.5 CPython/3.10.12

File hashes

Hashes for msgraph2-0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 43b67809fd5b37909e1fb6dab08b06fe275afef0a479480a1ec76a5a7e1a937f
MD5 42935c9ca242c804a00f7b4fc05294df
BLAKE2b-256 ba0c858704a93cb45e36a841b038979b3048d2c1fb152cdbbcf8cb4de98b9427

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page