-
Notifications
You must be signed in to change notification settings - Fork 34
Remove in-repo Teams CLI package #580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a559490
Remove in-repo Teams CLI package
heyitsaamir 4b9a994
Merge remote-tracking branch 'origin/main' into rm-old-cli
heyitsaamir 457cbf0
Remove toolkit references from active docs
heyitsaamir 0340d72
Refresh Graph auth README
heyitsaamir 8c93104
Merge remote-tracking branch 'origin/main' into rm-old-cli
heyitsaamir File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,70 +1,104 @@ | ||
| # Auth test | ||
| # Graph auth sample | ||
|
|
||
| Run this first to get all the config files: | ||
| This sample demonstrates signing a user in and calling Microsoft Graph with the `userGraph` client. | ||
|
|
||
| ## 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 | ||
|
heyitsaamir marked this conversation as resolved.
|
||
| teams login | ||
| ``` | ||
| teams config add atk.oauth | ||
|
|
||
| Expose this sample's local `/api/messages` endpoint with a tunnel, then create the Teams app: | ||
|
|
||
| ```bash | ||
| teams app create --name "graph" --endpoint "https://<your-tunnel>/api/messages" --env .env --json | ||
| ``` | ||
|
|
||
| Then run via ATK. | ||
| 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 Graph auth | ||
|
|
||
| This sample expects an OAuth connection named `graph`, matching `defaultConnectionName: 'graph'` in `src/index.ts`. | ||
|
|
||
| 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) flow: | ||
|
|
||
| 1. Make sure Azure CLI is installed and signed in with the same account used for `teams login`: | ||
|
|
||
| ```bash | ||
| az account show | ||
| ``` | ||
|
|
||
| ## Teams Toolkit Configuration: Oauth | ||
| 2. Check where the bot is hosted: | ||
|
|
||
| Use this if you want to enable user authentication in your Teams application. | ||
| ```bash | ||
| teams app bot get <teamsAppId> | ||
| ``` | ||
|
|
||
| ## How to update scopes | ||
| If the bot is Teams-managed, migrate it to Azure first: | ||
|
|
||
| 1. In the `aad.manifest.json` file, update the `requiredResourceAccess` list to add the required scopes. | ||
| ```bash | ||
| az group create --name <resourceGroup> --location <azureRegion> | ||
| teams app bot migrate <teamsAppId> --resource-group <resourceGroup> | ||
| ``` | ||
|
|
||
| 2. In the `infra/botRegistration/azurebot.bicep` file, under the `botServicesMicrosoftGraphConnection` resource, update the `properties.scopes` string to be a comma-delimited list of the required scopes. | ||
| 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. | ||
|
|
||
| ### Example | ||
| 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> | ||
| ``` | ||
|
|
||
| ## Updating Graph scopes | ||
|
|
||
| The default OAuth connection uses `User.Read`. To request more Microsoft Graph delegated permissions, update the OAuth connection scopes in Azure Bot Service. For example: | ||
|
|
||
| ```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 People.Read User.ReadBasic.All" \ | ||
| --parameters tenantId=<tenantId> tokenExchangeUrl=api://botid-<botId> \ | ||
| --subscription <subscription> | ||
| ``` | ||
|
|
||
| If you want to add the `People.Read.All` and `User.ReadBasic.All` scopes. | ||
| > Admin consent may be required depending on the scopes you add. | ||
|
|
||
| 1. Your `requiredResourceAccess` property should look like: | ||
| ## Run | ||
|
|
||
| ```json | ||
| "requiredResourceAccess": [ | ||
| { | ||
| "resourceAppId": "Microsoft Graph", | ||
| "resourceAccess": [ | ||
| { | ||
| "id": "People.Read.All", | ||
| "type": "Scope" | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "resourceAppId": "Microsoft Graph", | ||
| "resourceAccess": [ | ||
| { | ||
| "id": "User.ReadBasic.All", | ||
| "type": "Scope" | ||
| } | ||
| ] | ||
| }, | ||
| ] | ||
| ```bash | ||
| npm run dev | ||
| ``` | ||
|
|
||
| 2. Update the `properties.scopes` to be `People.Read.All,User.ReadBasic.All`. | ||
|
|
||
| ## Configuring a Regional Bot | ||
| NOTE: This example uses west europe, but follow the equivalent for other locations. | ||
|
|
||
| 1. In `azurebot.bicep`, replace all `global` occurrences to `westeurope` | ||
| 2. In `manifest.json`, in `validDomains`, `*.botframework.com` should be replaced by `europe.token.botframework.com` | ||
| 2. In `aad.manifest.json`, replace `https://token.botframework.com/.auth/web/redirect` with `https://europe.token.botframework.com/.auth/web/redirect` | ||
| 3. In `index.ts`, update `AppOptions` to include `apiClientSettings` | ||
|
|
||
| ```typescript | ||
| const app = new App({ | ||
| oauth: { | ||
| defaultConnectionName: 'graph', | ||
| }, | ||
| logger: new ConsoleLogger('@examples/auth', { level: 'debug' }), | ||
| apiClientSettings: { | ||
| oauthUrl: "https://europe.token.botframework.com", | ||
| } | ||
| }); | ||
| ``` | ||
| In Teams, send any message to start sign-in. After sign-in succeeds, the bot calls `GET /me` through Microsoft Graph and replies with the signed-in user's display name. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.