Skip to main content

Office 365 Library for Python

Project description

About

Office 365 & Microsoft Graph Library for Python

The list of supported APIs:

Status

Build Status PyPI

Installation

Use pip:

pip install Office365-REST-Python-Client

Usage

Working with SharePoint resources

There are two approaches available to perform REST queries:

  1. via ClientRequest class where you need to construct REST queries by specifying endpoint url, headers if required and payload (aka low level approach)

The first example demonstrates how to read Web resource:

import json

from office365.runtime.auth.authentication_context import AuthenticationContext
from office365.runtime.client_request import ClientRequest
from office365.runtime.utilities.request_options import RequestOptions

ctx_auth = AuthenticationContext(url)
if ctx_auth.acquire_token_for_user(username, password):
  request = ClientRequest(ctx_auth)
  options = RequestOptions("{0}/_api/web/".format(url))
  options.set_header('Accept', 'application/json')
  options.set_header('Content-Type', 'application/json')
  data = request.execute_request_direct(options)
  s = json.loads(data.content)
  web_title = s['Title']
  print "Web title: " + web_title
else:
  print ctx_auth.get_last_error()
  1. via ClientContext class where you target client object resources such as Web, ListItem and etc.
from office365.runtime.auth.authentication_context import AuthenticationContext
from office365.sharepoint.client_context import ClientContext

ctx_auth = AuthenticationContext(url)
if ctx_auth.acquire_token_for_user(username, password):
  ctx = ClientContext(url, ctx_auth)
  web = ctx.web
  ctx.load(web)
  ctx.execute_query()
  print "Web title: {0}".format(web.properties['Title'])

else:
  print ctx_auth.get_last_error()

Python Version

Python 2.7 & 3.4–3.6 are supported.

Third Party Libraries and Dependencies

The following libraries will be installed when you install the client library:

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

Office365-REST-Python-Client-2.1.4.tar.gz (37.2 kB view details)

Uploaded Source

File details

Details for the file Office365-REST-Python-Client-2.1.4.tar.gz.

File metadata

  • Download URL: Office365-REST-Python-Client-2.1.4.tar.gz
  • Upload date:
  • Size: 37.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.7

File hashes

Hashes for Office365-REST-Python-Client-2.1.4.tar.gz
Algorithm Hash digest
SHA256 68e7357738250bbbe29f2f57d9f2186e45c0cfe131326c3ed3605039b8e03769
MD5 0aabf94427622eb74c64bceb9ab2adeb
BLAKE2b-256 b5feec9ccd194ab42f9c15a0ce5586f5dce8387c85522913ab01cf4b09c238ca

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