Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ $: npm run test
- [`@examples/echo`](./examples/echo/README.md)
- [`@examples/auth`](./examples/auth/README.md)
- [`@examples/botbuilder`](./examples/botbuilder/README.md)
- [`@examples/graph`](./examples/graph/README.md)
- [`@examples/graph`](./examples/graph/README.md) — existing single-connection Graph authentication
- [`@examples/oauth`](./examples/oauth/README.md) — `OAuthFlow` lifecycle with multiple connections
- [`@examples/ai-mcp`](./examples/ai-mcp/README.md) — AI with the `openai` SDK + `@modelcontextprotocol/sdk`
- [`@examples/a2a`](./examples/a2a/README.md) — agent-to-agent with `@a2a-js/sdk`
- [`@examples/ai-file-analysis`](./examples/ai-file-analysis/README.md) — receiving attached files and sending them to a model
Expand Down
5 changes: 5 additions & 0 deletions examples/graph/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

This sample demonstrates signing a user in and calling Microsoft Graph with the `userGraph` client.

For new applications that need named flows or multiple OAuth connections, use the
[multi-provider OAuth sample](../oauth/README.md), which demonstrates the `OAuthFlow`
registration and lifecycle APIs. This sample remains focused on the existing
single-connection context helpers.

## Teams CLI

Use the official Teams CLI (`@microsoft/teams.cli`) to create and manage the Teams app for this sample:
Expand Down
2 changes: 1 addition & 1 deletion examples/graph/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@examples/auth",
"name": "@examples/graph",
"version": "0.0.6",
"private": true,
"license": "MIT",
Expand Down
6 changes: 6 additions & 0 deletions examples/oauth/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
teams*.yml
env/
infra/
node_modules/
.vscode/
aad.manifest.json
214 changes: 214 additions & 0 deletions examples/oauth/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
# @examples/oauth

## 0.0.6

### Patch Changes

- Updated dependencies
- @microsoft/teams.api@2.0.5
- @microsoft/teams.apps@2.0.5
- @microsoft/teams.cards@2.0.5
- @microsoft/teams.common@2.0.5
- @microsoft/teams.dev@2.0.5
- @microsoft/teams.graph@2.0.5
- @microsoft/teams.graph-endpoints@2.0.5

## 0.0.5

### Patch Changes

- Updated dependencies
- @microsoft/teams.api@2.0.4
- @microsoft/teams.apps@2.0.4
- @microsoft/teams.cards@2.0.4
- @microsoft/teams.common@2.0.4
- @microsoft/teams.dev@2.0.4
- @microsoft/teams.graph@2.0.4
- @microsoft/teams.graph-endpoints@2.0.4

## 0.0.4

### Patch Changes

- Updated dependencies
- @microsoft/teams.api@2.0.3
- @microsoft/teams.apps@2.0.3
- @microsoft/teams.cards@2.0.3
- @microsoft/teams.common@2.0.3
- @microsoft/teams.dev@2.0.3
- @microsoft/teams.graph@2.0.3
- @microsoft/teams.graph-endpoints@2.0.3

## 0.0.3

### Patch Changes

- Updated dependencies
- @microsoft/teams.api@2.0.2
- @microsoft/teams.apps@2.0.2
- @microsoft/teams.cards@2.0.2
- @microsoft/teams.common@2.0.2
- @microsoft/teams.dev@2.0.2
- @microsoft/teams.graph@2.0.2
- @microsoft/teams.graph-endpoints@2.0.2

## 0.0.2

### Patch Changes

- Updated dependencies
- @microsoft/teams.api@2.0.1
- @microsoft/teams.apps@2.0.1
- @microsoft/teams.cards@2.0.1
- @microsoft/teams.common@2.0.1
- @microsoft/teams.dev@2.0.1
- @microsoft/teams.graph@2.0.1
- @microsoft/teams.graph-endpoints@2.0.1

## 0.0.1

### Patch Changes

- Updated dependencies [a231813]
- Updated dependencies [05085e8]
- Updated dependencies [7a0e5f6]
- Updated dependencies [1d5f350]
- Updated dependencies [9bc2cee]
- Updated dependencies [9b08518]
- Updated dependencies [00d3edb]
- Updated dependencies [ee61ca0]
- Updated dependencies [70cb729]
- Updated dependencies [2337a4f]
- Updated dependencies [e6f9b56]
- Updated dependencies [9e2414b]
- Updated dependencies [753af04]
- @microsoft/teams.api@2.0.0
- @microsoft/teams.apps@2.0.0
- @microsoft/teams.cards@2.0.0
- @microsoft/teams.common@2.0.0
- @microsoft/teams.dev@2.0.0
- @microsoft/teams.graph@2.0.0
- @microsoft/teams.graph-endpoints@2.0.0

## 0.0.1-preview.12

### Patch Changes

- Updated dependencies
- @microsoft/teams.api@2.0.0-preview.12
- @microsoft/teams.apps@2.0.0-preview.12
- @microsoft/teams.cards@2.0.0-preview.12
- @microsoft/teams.common@2.0.0-preview.12
- @microsoft/teams.dev@2.0.0-preview.12
- @microsoft/teams.graph@2.0.0-preview.12
- @microsoft/teams.graph-endpoints@2.0.0-preview.12

## 0.0.1-preview.11

### Patch Changes

- Updated dependencies
- @microsoft/teams.api@2.0.0-preview.11
- @microsoft/teams.apps@2.0.0-preview.11
- @microsoft/teams.cards@2.0.0-preview.11
- @microsoft/teams.common@2.0.0-preview.11
- @microsoft/teams.dev@2.0.0-preview.11
- @microsoft/teams.graph@2.0.0-preview.11
- @microsoft/teams.graph-endpoints@2.0.0-preview.11

## 0.0.1-preview.10

### Patch Changes

- Updated dependencies
- @microsoft/teams.api@2.0.0-preview.10
- @microsoft/teams.apps@2.0.0-preview.10
- @microsoft/teams.cards@2.0.0-preview.10
- @microsoft/teams.common@2.0.0-preview.10
- @microsoft/teams.dev@2.0.0-preview.10
- @microsoft/teams.graph@2.0.0-preview.10
- @microsoft/teams.graph-endpoints@2.0.0-preview.10

## 0.0.1-preview.9

### Patch Changes

- Updated dependencies
- @microsoft/teams.api@2.0.0-preview.9
- @microsoft/teams.apps@2.0.0-preview.9
- @microsoft/teams.cards@2.0.0-preview.9
- @microsoft/teams.common@2.0.0-preview.9
- @microsoft/teams.dev@2.0.0-preview.9
- @microsoft/teams.graph@2.0.0-preview.9

## 0.0.1-preview.8

### Patch Changes

- Updated dependencies
- @microsoft/teams.api@2.0.0-preview.8
- @microsoft/teams.apps@2.0.0-preview.8
- @microsoft/teams.cards@2.0.0-preview.8
- @microsoft/teams.common@2.0.0-preview.8
- @microsoft/teams.dev@2.0.0-preview.8
- @microsoft/teams.graph@2.0.0-preview.8

## 0.0.1-preview.7

### Patch Changes

- Updated dependencies
- @microsoft/teams.api@2.0.0-preview.7
- @microsoft/teams.apps@2.0.0-preview.7
- @microsoft/teams.cards@2.0.0-preview.7
- @microsoft/teams.common@2.0.0-preview.7
- @microsoft/teams.dev@2.0.0-preview.7
- @microsoft/teams.graph@2.0.0-preview.7

## 0.0.1-preview.6

### Patch Changes

- Updated dependencies
- @microsoft/teams.api@2.0.0-preview.6
- @microsoft/teams.apps@2.0.0-preview.6
- @microsoft/teams.cards@2.0.0-preview.6
- @microsoft/teams.common@2.0.0-preview.6
- @microsoft/teams.dev@2.0.0-preview.6
- @microsoft/teams.graph@2.0.0-preview.6

## 0.0.1-preview.5

### Patch Changes

- Updated dependencies
- @microsoft/teams.apps@2.0.0-preview.5
- @microsoft/teams.api@2.0.0-preview.5
- @microsoft/teams.cards@2.0.0-preview.5
- @microsoft/teams.common@2.0.0-preview.5
- @microsoft/teams.dev@2.0.0-preview.5
- @microsoft/teams.graph@2.0.0-preview.5

## 0.0.1-preview.4

### Patch Changes

- Updated dependencies
- @microsoft/teams.api@2.0.0-preview.4
- @microsoft/teams.apps@2.0.0-preview.4
- @microsoft/teams.cards@2.0.0-preview.4
- @microsoft/teams.common@2.0.0-preview.4
- @microsoft/teams.dev@2.0.0-preview.4
- @microsoft/teams.graph@2.0.0-preview.4

## 0.0.1-preview.3

### Patch Changes

- Updated dependencies
- @microsoft/teams.api@2.0.0-preview.3
- @microsoft/teams.apps@2.0.0-preview.3
- @microsoft/teams.cards@2.0.0-preview.3
- @microsoft/teams.common@2.0.0-preview.3
- @microsoft/teams.dev@2.0.0-preview.3
- @microsoft/teams.graph@2.0.0-preview.3
119 changes: 119 additions & 0 deletions examples/oauth/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# Multi-provider OAuth sample

This sample registers independent `graph` and `github` OAuth flows. Each flow
owns its sign-in completion/failure callbacks and can be queried or signed out
without affecting the other connection.

## Teams CLI

Use the official Teams CLI (`@microsoft/teams.cli`) to create and manage the Teams app for this sample:

```bash
npm install -g @microsoft/teams.cli
teams --version
teams login
```

Expose this sample's local `/api/messages` endpoint with a tunnel, then create the Teams app:

```bash
teams app create --name "oauth" --endpoint "https://<your-tunnel>/api/messages" --env .env --json
```

The CLI writes `CLIENT_ID`, `CLIENT_SECRET`, and `TENANT_ID` to your `.env` file and prints an install link for Teams. Save the `teamsAppId` and `botId` from the JSON output for the auth setup below.

## Configure Microsoft Graph

The `graph` connection is the default and supports Teams SSO. Follow the Teams
SDK [SSO setup guide](https://github.com/microsoft/teams-sdk/blob/main/plugins/teams-sdk/skills/teams-dev/references/guide-setup-sso.md).

1. Make sure Azure CLI is installed and signed in with the same account used for `teams login`:

```bash
az account show
```

2. Check where the bot is hosted:

```bash
teams app bot get <teamsAppId>
```

If the bot is Teams-managed, migrate it to Azure first:

```bash
az group create --name <resourceGroup> --location <azureRegion>
teams app bot migrate <teamsAppId> --resource-group <resourceGroup>
```

3. Create or reuse the bot client secret from `.env`, then configure the AAD app identifier URI, `access_as_user` scope, Teams pre-authorization, and Bot Framework redirect URI as described in the SSO setup guide.

4. Create the Azure Bot OAuth connection named `graph`:

```bash
az bot authsetting create \
--name <botId> \
--resource-group <resourceGroup> \
--setting-name "graph" \
--service Aadv2 \
--client-id <botId> \
--client-secret <clientSecret> \
--provider-scope-string "User.Read" \
--parameters tenantId=<tenantId> tokenExchangeUrl=api://botid-<botId> \
--subscription <subscription>
```

5. Set the Teams app SSO identity fields:

```bash
teams app update <teamsAppId> \
--web-app-info-id "<botId>" \
--web-app-info-resource "api://botid-<botId>"
```

6. Verify the setup:

```bash
teams app doctor <teamsAppId>
```

## Configure GitHub

1. Create a GitHub OAuth app with this authorization callback URL:

```text
https://token.botframework.com/.auth/web/redirect
```

2. Create the second Azure Bot OAuth connection:

```bash
az bot authsetting create \
--name <botId> \
--resource-group <resourceGroup> \
--setting-name "github" \
--service GitHub \
--client-id <githubClientId> \
--client-secret <githubClientSecret> \
--provider-scope-string "read:user user:email" \
--subscription <subscription>
```

The connection name must be `github`, matching the `github` entry in `oauthFlows` in
`src/index.ts`.

## Run

```bash
npm run dev
```

Use these commands in Teams:

| Command | Action |
| --- | --- |
| `/graph` | Sign in and call Microsoft Graph `GET /me`. |
| `/github` | Sign in and call GitHub `GET /user`. |
| `/status` | Show both token-service connection statuses. |
| `/signout graph` | Sign out only from Microsoft Graph. |
| `/signout github` | Sign out only from GitHub. |
3 changes: 3 additions & 0 deletions examples/oauth/appPackage/color.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading