Skip to main content

Library to interact with Microsoft Planner via API Graph

Project description

MSPlanner Tools Documentation

MSPlanner Tools is a Python library designed to streamline interactions with Microsoft Planner via the Microsoft Graph API. This documentation provides an overview of the library's features, focusing on Authentication and managing OAuth2 tokens using the TokenManager class.

Overview

Authentication

The TokenManager class provides a robust way to handle authentication and token management for accessing the Microsoft Graph API. This is essential for secure and seamless communication with Microsoft Planner.

Features of TokenManager

  • Automatically manages OAuth2 tokens for authentication.
  • Requests new tokens when the current token expires.
  • Supports Azure Active Directory authentication using the Microsoft Authentication Library (MSAL).

Prerequisites

Before using the TokenManager class, ensure you have the following:

  • Client ID: Obtain from your Azure AD app registration.
  • Client Secret: Set up in your Azure AD app registration.
  • Tenant ID: Find this in your Azure Active Directory overview.

Usage

Here's how to use the TokenManager class for authentication:

Import and Initialize

from msplanner_tools.authentication import TokenManager

# Replace with your Azure AD app credentials
client_id = 'your_client_id'
client_secret = 'your_client_secret'
tenant_id = 'your_tenant_id'

If you don't know how to register an Azure app, visit Microsoft how to register an app guide.

Permissions:

  • Group.ReadWrite.All
  • Tasks.ReadWrite.All
  • User.ReadBasic.All

Here is an example on how to use the TokenManager class:

# Initialize the TokenManager
token_manager = TokenManager(client_id=client_id, client_secret=client_secret, tenant_id=tenant_id)

# Get a valid access token
access_token = token_manager.get_token()
print(f'Access Token: {access_token}')
# The get_token method ensures that a valid token is always returned, automatically handling token expiration.

Token Management Details

  • Request a New Token: If the token has expired or is unavailable, a new token is automatically requested using request_new_token.
  • Expiration Handling: The class keeps track of the token's expiration time and validates it using is_token_expired.

Example Workflow

# Using the token in an API request
import requests

# Get the access token
access_token = token_manager.get_token()

# Set up the headers for Microsoft Graph API requests
headers = {
    'Authorization': f'Bearer {access_token}',
    'Content-Type': 'application/json'
}

Example: Create a new plan

from msplanner_tools.plans import create_plan
from msplanner_tools.auth import TokenManager

token_manager = TokenManager(client_id=client_id, client_secret=client_secret, tenant_id=tenant_id)

plan_id = create_plan("my new plan", "my_group_id", token_manager.get_token())

if plan_id:
    print("Plan successfully created!")

References

Next, continue to Plans, Tasks, and Buckets for interacting with Microsoft Planner resources. Plans

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

msplanner-tools-0.1.6.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

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

msplanner_tools-0.1.6-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file msplanner-tools-0.1.6.tar.gz.

File metadata

  • Download URL: msplanner-tools-0.1.6.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.10

File hashes

Hashes for msplanner-tools-0.1.6.tar.gz
Algorithm Hash digest
SHA256 31dcb2c8a1b068b9f386567d5517c0b3ca925a73f0d3796df5b53285201c4ff5
MD5 9b6f3548a338d45f55f4754e083c794e
BLAKE2b-256 f13c1c88fabad10e8104ec135bd5550b60f7be2759d30d97cdbca08e5df33692

See more details on using hashes here.

File details

Details for the file msplanner_tools-0.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for msplanner_tools-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 20a99675dd30e2d1755e351e309bd915c53e42e32f401c512073e8e6631afc7d
MD5 c3247169e55fdbf73ee526ecf378e513
BLAKE2b-256 1ac04da8832a7c63a6b9e179d760c74582d14f318c51f2b7ec2e6f85f067b3be

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