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.5.tar.gz (9.1 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.5-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: msplanner-tools-0.1.5.tar.gz
  • Upload date:
  • Size: 9.1 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.5.tar.gz
Algorithm Hash digest
SHA256 e76993d7e130680a18ee4d32ea5e3f1bf93ac8da04a424aca87c3d1b21822a0d
MD5 b384978c7815d0541739dc61d3988252
BLAKE2b-256 81a7650c2997eebc6dbe1c23497afcc9e6d9c4d9ebf8510264102683806a59a0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for msplanner_tools-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 a2edca4b265235d184bbf9bb1b3f520f14511af28a49c22e94b176a66b1a9ace
MD5 e80f3be92f9587715497edb8c9988214
BLAKE2b-256 4cd9304c8f36285695662409c2d24f653b3f29612872798749192aca0d0c61df

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