Skip to content
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

Implement New toolkit version csharp samples #1445

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 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
25 changes: 25 additions & 0 deletions samples/app-anonymous-users/csharp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# TeamsFx files
build
appPackage/build
env/.env.*.user
env/.env.local
appsettings.Development.json
.deployment

# User-specific files
*.user

# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/

# Notification local store
.notification.localstore.json
6 changes: 6 additions & 0 deletions samples/app-anonymous-users/csharp/AnonymousUsers.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ VisualStudioVersion = 17.3.32901.215
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AnonymousUsers", "AnonymousUsers.csproj", "{76D60C04-94EB-4042-B141-C2C0FACBDE94}"
EndProject
Project("{A9E3F50B-275E-4AF7-ADCE-8BE12D41E305}") = "TeamsApp", "TeamsApp\TeamsApp.ttkproj", "{925F02F4-663A-41F1-8293-F00A8B45EE29}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -15,6 +17,10 @@ Global
{76D60C04-94EB-4042-B141-C2C0FACBDE94}.Debug|Any CPU.Build.0 = Debug|Any CPU
{76D60C04-94EB-4042-B141-C2C0FACBDE94}.Release|Any CPU.ActiveCfg = Release|Any CPU
{76D60C04-94EB-4042-B141-C2C0FACBDE94}.Release|Any CPU.Build.0 = Release|Any CPU
{925F02F4-663A-41F1-8293-F00A8B45EE29}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{925F02F4-663A-41F1-8293-F00A8B45EE29}.Debug|Any CPU.Build.0 = Debug|Any CPU
{925F02F4-663A-41F1-8293-F00A8B45EE29}.Release|Any CPU.ActiveCfg = Release|Any CPU
{925F02F4-663A-41F1-8293-F00A8B45EE29}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
28 changes: 7 additions & 21 deletions samples/app-anonymous-users/csharp/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,14 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:3978",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
".NET Core": {

"Start Project": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "http://localhost:3978",
"dotnetRunMessages": true,
"applicationUrl": "https://localhost:3978",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"hotReloadProfile": "aspnetcore"
}
}
}
}
25 changes: 23 additions & 2 deletions samples/app-anonymous-users/csharp/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,27 @@ This sample demonstrates how to enable anonymous user support in Microsoft Teams
```
- [dev tunnel](https://learn.microsoft.com/en-us/azure/developer/dev-tunnels/get-started?tabs=windows) or [ngrok](https://ngrok.com/) latest version or equivalent tunnelling solution.
- [Teams](https://teams.microsoft.com) Microsoft Teams is installed and you have an account
-[Teams Toolkit for Visual Studio](https://learn.microsoft.com/en-us/microsoftteams/platform/toolkit/toolkit-v4/install-teams-toolkit-vs?pivots=visual-studio-v17-7)

##Run the app (Using Teams Toolkit for Visual Studio)

The simplest way to run this sample in Teams is to use Teams Toolkit for Visual Studio.

1.Install Visual Studio 2022 Version 17.10 Preview 4 or higher Visual Studio
2.Install Teams Toolkit for Visual Studio Teams Toolkit extension
3.In the debug dropdown menu of Visual Studio, select Dev Tunnels > Create A Tunnel (set authentication type to Public) or select an existing public dev tunnel.
4.In the debug dropdown menu of Visual Studio, select default startup project > Microsoft Teams (browser)
5.In Visual Studio, right-click your TeamsApp project and Select Teams Toolkit > Prepare Teams App Dependencies
6.Using the extension, sign in with your Microsoft 365 account where you have permissions to upload custom apps.
7.To test facebook auth flow create a facebookapp and get client id and secret for facebook app. Now go to your bot channel registartion -> configuration -> Add OAuth connection string

Provide connection Name : for eg facebookconnection. You'll use this name in your bot in the appsettings.json file.
Select service provider ad facebook
Update {{FacebookAppId}} and {{FacebookAppPassword}} in appsetting.json.
8.Select Debug > Start Debugging or F5 to run the menu in Visual Studio.
9.In the browser that launches, select the Add button to install the app to Teams.

If you do not have permission to upload custom apps (sideloading), Teams Toolkit will recommend creating and using a Microsoft 365 Developer Program account - a free program to get your own dev environment sandbox that includes Teams.

## Setup

Expand Down Expand Up @@ -144,11 +165,11 @@ This sample demonstrates how to enable anonymous user support in Microsoft Teams

7. __*This step is specific to Teams.*__

- **Edit** the `manifest.json` contained in the `AppManifest` folder to replace your Microsoft App Id `<<YOUR-MICROSOFT-APP-ID>>` (that was created when you registered your bot earlier) *everywhere* you see the place holder string `<<YOUR-MICROSOFT-APP-ID>>` (depending on the scenario the Microsoft App Id may occur multiple times in the `manifest.json`)
- **Edit** the `manifest.json` contained in the `appPackage` folder to replace your Microsoft App Id `<<YOUR-MICROSOFT-APP-ID>>` (that was created when you registered your bot earlier) *everywhere* you see the place holder string `<<YOUR-MICROSOFT-APP-ID>>` (depending on the scenario the Microsoft App Id may occur multiple times in the `manifest.json`)

- **Edit** the `manifest.json` for `{{domain-name}}` with base Url domain. E.g. if you are using ngrok it would be `https://1234.ngrok-free.app` then your domain-name will be `1234.ngrok-free.app` and if you are using dev tunnels then your domain will be like: `12345.devtunnels.ms`.

- **Zip** up the contents of the `AppManifest` folder to create a `manifest.zip` (Make sure that zip file does not contains any subfolder otherwise you will get error while uploading your .zip package)
- **Zip** up the contents of the `appPackage` folder to create a `manifest.zip` (Make sure that zip file does not contains any subfolder otherwise you will get error while uploading your .zip package)

- **Upload** the `manifest.zip` to Teams (In Teams Apps/Manage your apps click "Upload an app". Browse to and Open the .zip file. At the next dialog, click the Add button.)

Expand Down
9 changes: 9 additions & 0 deletions samples/app-anonymous-users/csharp/TeamsApp/TeamsApp.ttkproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" Sdk="Microsoft.TeamsFx.Sdk">
<PropertyGroup Label="Globals">
<ProjectGuid>925f02f4-663a-41f1-8293-f00a8b45ee29</ProjectGuid>
</PropertyGroup>
<ItemGroup>
<ProjectCapability Include="ProjectConfigurationsDeclaredDimensions" />
</ItemGroup>
</Project>
107 changes: 107 additions & 0 deletions samples/app-anonymous-users/csharp/TeamsApp/aad.manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
{
"id": "${{AAD_APP_OBJECT_ID}}",
"appId": "${{AAD_APP_CLIENT_ID}}",
"name": "app-anonymous-users-aad",
"accessTokenAcceptedVersion": 2,
"signInAudience": "AzureADMultipleOrgs",
"oauth2AllowIdTokenImplicitFlow": true,
"oauth2AllowImplicitFlow": true,
"optionalClaims": {
"idToken": [],
"accessToken": [
{
"name": "idtyp",
"source": null,
"essential": false,
"additionalProperties": []
}
],
"saml2Token": []
},
"requiredResourceAccess": [
{
"resourceAppId": "Microsoft Graph",
"resourceAccess": [
{
"id": "User.Read",
"type": "Scope"
}
]
}
],
"oauth2Permissions": [
{
"adminConsentDescription": "Allows Teams to call the app's web APIs as the current user.",
"adminConsentDisplayName": "Teams can access app's web APIs",
"id": "${{AAD_APP_ACCESS_AS_USER_PERMISSION_ID}}",
"isEnabled": true,
"type": "User",
"userConsentDescription": "Enable Teams to call this app's web APIs with the same rights that you have",
"userConsentDisplayName": "Teams can access app's web APIs and make requests on your behalf",
"value": "access_as_user"
}
],
"preAuthorizedApplications": [
{
"appId": "1fec8e78-bce4-4aaf-ab1b-5451cc387264",
"permissionIds": [
"${{AAD_APP_ACCESS_AS_USER_PERMISSION_ID}}"
]
},
{
"appId": "5e3ce6c0-2b1f-4285-8d4b-75ee78787346",
"permissionIds": [
"${{AAD_APP_ACCESS_AS_USER_PERMISSION_ID}}"
]
},
{
"appId": "d3590ed6-52b3-4102-aeff-aad2292ab01c",
"permissionIds": [
"${{AAD_APP_ACCESS_AS_USER_PERMISSION_ID}}"
]
},
{
"appId": "00000002-0000-0ff1-ce00-000000000000",
"permissionIds": [
"${{AAD_APP_ACCESS_AS_USER_PERMISSION_ID}}"
]
},
{
"appId": "bc59ab01-8403-45c6-8796-ac3ef710b3e3",
"permissionIds": [
"${{AAD_APP_ACCESS_AS_USER_PERMISSION_ID}}"
]
},
{
"appId": "0ec893e0-5785-4de6-99da-4ed124e5296c",
"permissionIds": [
"${{AAD_APP_ACCESS_AS_USER_PERMISSION_ID}}"
]
},
{
"appId": "4765445b-32c6-49b0-83e6-1d93765276ca",
"permissionIds": [
"${{AAD_APP_ACCESS_AS_USER_PERMISSION_ID}}"
]
},
{
"appId": "4345a7b9-9a63-4910-a426-35363201d503",
"permissionIds": [
"${{AAD_APP_ACCESS_AS_USER_PERMISSION_ID}}"
]
}
],
"identifierUris":[
"api://botid-${{AAD_APP_CLIENT_ID}}"
],
"replyUrlsWithType":[
{
"url": "https://${{BOT_DOMAIN}}/auth-end.html",
"type": "Web"
},
{
"url": "https://token.botframework.com/.auth/web/redirect",
"type": "Web"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://developer.microsoft.com/json-schemas/teams/v1.16/MicrosoftTeams.schema.json",
"manifestVersion": "1.16",
"version": "1.0.0",
"id": "{{Microsoft-App-id}}",
"id": "${{TEAMS_APP_ID}}",
"packageName": "com.teams.sample.appAnonymousUsers",
"developer": {
"name": "appAnonymousUsers",
Expand All @@ -19,13 +19,13 @@
"full": "Anonymous User Support"
},
"description": {
"short": "Enable anonymous user participation in Teams meeting apps with this sample.",
"full": "This sample demonstrates how to support anonymous users in Microsoft Teams meeting apps, showcasing the setup and interaction flow for integrating guest and tenant users seamlessly."
"short": "This sample shows anonymous users support in Teams meeting apps.",
"full": "This sample shows anonymous users support in Teams meeting apps."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be detailed.

Copy link
Contributor Author

@Harikrishnan-MSFT Harikrishnan-MSFT Nov 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated Below Comments -
This sample app enables anonymous user support in Microsoft Teams meeting apps using Azure AD, Bot Framework, and tunneling setup, allowing guest users to interact seamlessly through features like meeting tabs and stage views.

},
"accentColor": "#FFFFFF",
"configurableTabs": [
{
"configurationUrl": "https://{{domain-name}}/configure",
"configurationUrl": "https://${{BOT_DOMAIN}}/configure",
"canUpdateConfiguration": true,
"scopes": [
"team",
Expand All @@ -39,7 +39,7 @@
],
"bots": [
{
"botId": "{{Microsoft-App-id}}",
"botId": "${{AAD_APP_CLIENT_ID}}",
"scopes": [
"groupChat",
"team"
Expand Down Expand Up @@ -76,11 +76,11 @@
"messageTeamMembers"
],
"validDomains": [
"{{domain-name}}"
"${{BOT_DOMAIN}}"
],
"webApplicationInfo": {
"id": "{{Microsoft-App-id}}",
"resource": "api://{{domain-name}}/botid-{{Microsoft-App-id}}"
"id": "${{AAD_APP_CLIENT_ID}}",
"resource": "api://${{BOT_DOMAIN}}/botid-${{AAD_APP_CLIENT_ID}}"
},
"authorization": {
"permissions": {
Expand Down
27 changes: 27 additions & 0 deletions samples/app-anonymous-users/csharp/TeamsApp/env/.env.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# This file includes environment variables that can be committed to git. It's gitignored by default because it represents your local development environment.

# Built-in environment variables
TEAMSFX_ENV=
APP_NAME_SUFFIX=

# Generated during provision, you can also add your own variables.
BOT_ID=
TEAMS_APP_ID=
TEAMSFX_M365_USER_NAME=

BOT_ENDPOINT=
BOT_DOMAIN=

RESOURCE_SUFFIX=
AZURE_SUBSCRIPTION_ID=
AZURE_RESOURCE_GROUP_NAME=
AAD_APP_CLIENT_ID=
AAD_APP_OBJECT_ID=
AAD_APP_TENANT_ID=
AAD_APP_OAUTH_AUTHORITY=
AAD_APP_OAUTH_AUTHORITY_HOST=
TEAMS_APP_TENANT_ID=
MICROSOFT_APP_TYPE=
MICROSOFT_APP_TENANT_ID=
CONNECTION_NAME=
AAD_APP_ACCESS_AS_USER_PERMISSION_ID=
Loading