Skip to main content

Microsoft Graph convenience library

Project description

wmgraph Microsoft Graph convenience library

This library aids with the Microsoft graph API for Office 365 business. It uses certificates for the OAuth 2.0 client credentials flow to authenticate a daemon application registered in Azure AD. This makes it suitable to be used in console applications.

Configuration

as described in A simple Python daemon console application calling Microsoft Graph with its own identity, client certificate variation

  • Register an application in Azure AD
  • Prepare a config.json and certificates for a MS Application
  • Upload the server.crt to AAD

see Client Credentials for AzureAD msal

Create Certificates:

#!/bin/sh
openssl genrsa -out server.pem 2048
openssl req -new -key server.pem -out server.csr
openssl x509 -req -days 365 -in server.csr -signkey server.pem -out server.crt
openssl x509 -noout -fingerprint -sha1 -inform pem -in server.crt |sed -e 's=:==g' > server.fpr

config.json:

{
    "authority": "https://login.microsoftonline.com/TENANT_ID",
    "client_id": "CLIENT_ID",
    "scope": [ "https://graph.microsoft.com/.default" ],
    "thumbprint": "SRERVER.CRT.FINGERPRINT",
    "private_key_file": "PATH_TO_CERTS(can be relative)/server.pem",
    "endpoint": "https://graph.microsoft.com/v1.0"
}

Usage

import

from wmgraph.api import MgraphApi
from wmgraph.api.exceptions import MgraphApiError

connect

api = MgraphApi(params='./config.json')

use

userdata = api.get_user(args.user_id)

or

for user in api.list_users():
    print(user)`

Development requirements

twine wheel

Project details


Download files

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

Source Distribution

wmgraph-0.7.1.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wmgraph-0.7.1-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file wmgraph-0.7.1.tar.gz.

File metadata

  • Download URL: wmgraph-0.7.1.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.6

File hashes

Hashes for wmgraph-0.7.1.tar.gz
Algorithm Hash digest
SHA256 d73b736a5e02d30618ff0a55607e07472138261d5f8a3aff3aa2d480465a0263
MD5 c3752bfc80d1440cbd78ce70b939a426
BLAKE2b-256 7c759641365fa89155abb641de62130714cc933f38cff9e521b798e77044dd20

See more details on using hashes here.

File details

Details for the file wmgraph-0.7.1-py3-none-any.whl.

File metadata

  • Download URL: wmgraph-0.7.1-py3-none-any.whl
  • Upload date:
  • Size: 12.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.6

File hashes

Hashes for wmgraph-0.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a7d83246ff59fae21ec4a2320c4878cbc76b989a99197836d39e01154ee04d45
MD5 a1652db199328cdb26a8595b198c72e1
BLAKE2b-256 aa3910188ad9e2409f597f34007226a1e35207a7b10c70ae382dfacb17f6fa8c

See more details on using hashes here.

Supported by

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