Microsoft Teams Apps Framework
High-level framework for building Microsoft Teams applications. Handles activity routing, authentication, and provides Microsoft Graph integration.
Features
- Activity Routing: Decorator-based routing for different activity types
- OAuth Integration: Built-in OAuth flow handling for user authentication
- Microsoft Graph Integration: Type-safe Graph client access via
user_graphandapp_graphproperties - Plugin System: Extensible plugin architecture for adding functionality
Basic Usage
from microsoft_teams.apps import App, ActivityContext
from microsoft_teams.api import MessageActivity
app = App()
@app.on_message
async def handle_message(ctx: ActivityContext[MessageActivity]):
await ctx.send(f"You said: {ctx.activity.text}")
# Start the app
await app.start()
Unauthenticated Requests
For local development only, JWT validation can be disabled explicitly:
app = App(dangerously_allow_unauthenticated_requests=True)
It can also be enabled with the DANGEROUSLY_ALLOW_UNAUTHENTICATED_REQUESTS=true environment variable.
The previous skip_auth option is deprecated and remains supported for compatibility.
OAuth and Graph Integration
@app.on_message
async def handle_message(ctx: ActivityContext[MessageActivity]):
if ctx.is_signed_in:
try:
# Access user's Graph data
me = await ctx.user_graph.me.get()
await ctx.send(f"Hello {me.display_name}!")
except (ValueError, RuntimeError, ImportError) as e:
await ctx.send(f"Graph access failed: {e}")
else:
# Prompt user to sign in
await ctx.sign_in()
Optional Graph Dependencies
Microsoft Graph functionality requires additional dependencies:
pip install microsoft-teams-apps[graph]
Or if using uv:
uv add microsoft-teams-apps[graph]
If Graph dependencies are not installed, user_graph and app_graph will raise an ImportError when accessed. If the user is not signed in or tokens are unavailable, they will raise ValueError.
Metadata
Release files for microsoft-teams-apps 2.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| microsoft_teams_apps-2.1.1.tar.gz | 228.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| microsoft_teams_apps-2.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 374.9 kB
Release files / microsoft_teams_apps-2.1.1.tar.gz
| Download URL | microsoft_teams_apps-2.1.1.tar.gz |
|---|---|
| Size | 228.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d0ba52d41cdc44cc3dbe5ac549ee0a9dc84392884a69e7f4e29c2e0e688f57b3
|
|
BLAKE2b-256 checksum How to use checksums |
72fcd045e348f63a1abc6496c2cfd0ce4c9db309c91c945909a14b5d5dfde812
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
RestSharp/106.13.0.0
|
Release files / microsoft_teams_apps-2.1.1-py3-none-any.whl
| Download URL | microsoft_teams_apps-2.1.1-py3-none-any.whl |
|---|---|
| Size | 146.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
91c1932bb22a88619ef7144c45e7023e09e05acc3c358c81d21b42f90792faeb
|
|
BLAKE2b-256 checksum How to use checksums |
6d65da0ff6ade74ebba93e2a311b25b9249e0e799a8ebaa677485510d0c6d519
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
RestSharp/106.13.0.0
|