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

added changes to run sample in gcch tenant #1167

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ public async Task AuthenticateOutboundRequestAsync(HttpRequestMessage request, s
{
const string schema = "Bearer";
const string replaceString = "{tenant}";
const string oauthV2TokenLink = "https://login.microsoftonline.com/{tenant}";
const string resource = "https://graph.microsoft.com";
const string oauthV2TokenLink = "https://login.microsoftonline.us/{tenant}";
const string resource = "https://graph.microsoft.us";

// If no tenant was specified, we craft the token link using the common tenant.
// https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-v2-protocols#endpoints
Expand Down Expand Up @@ -112,7 +112,7 @@ public async Task<RequestValidationResult> ValidateInboundRequestAsync(HttpReque
// Currently the service does not sign outbound request using AAD, instead it is signed
// with a private certificate. In order for us to be able to ensure the certificate is
// valid we need to download the corresponding public keys from a trusted source.
const string authDomain = "https://api.aps.skype.com/v1/.well-known/OpenIdConfiguration";
const string authDomain = "https://api.aps.skype.us/v1/.well-known/OpenIdConfiguration";
if (this.openIdConfiguration == null || DateTime.Now > this.prevOpenIdConfigUpdateTimestamp.Add(this.openIdConfigRefreshInterval))
{
this.GraphLogger.Info("Updating OpenID configuration");
Expand All @@ -130,8 +130,8 @@ public async Task<RequestValidationResult> ValidateInboundRequestAsync(HttpReque
// The incoming token should be issued by graph.
var authIssuers = new[]
{
"https://graph.microsoft.com",
"https://api.botframework.com",
"https://graph.microsoft.us",
"https://api.botframework.us",
};

// Configure the TokenValidationParameters.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,12 @@ protected override async Task<TaskModuleResponse> OnTeamsTaskModuleSubmitAsync(I
if (peoplePicker != null)
{
// Adaptive Card people picker returns a comma separated list of aad IDs
//var peoplePickerAadIds = new[] { "d30034ff-f3da-4fd0-8e25-b227d5a40805" };

//var peoplePickerID = new[] { "3e96496e-e5bb-4507-a1ea-cafb38d735e7" };

var peoplePickerAadIds = peoplePicker.Split(',');

var action = moduleSubmitData?.Action?.ToLowerInvariant();
var callId = moduleSubmitData?.CallId;

Expand Down Expand Up @@ -164,7 +169,7 @@ protected override async Task<TaskModuleResponse> OnTeamsTaskModuleSubmitAsync(I
callId,
(nonNullCallId) => callService.InviteParticipant(
nonNullCallId,
new[] { new IdentitySet { User = new Identity { Id = peoplePicker } } }),
new[] { new IdentitySet { User = new Identity { Id = "3e96496e-e5bb-4507-a1ea-cafb38d735e7" } } }),
CreateTaskModuleMessageResponse);
case "createincident":
if (moduleSubmitData?.IncidentName != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@
</Content>
</ItemGroup>

</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ public static MeetingInfo ParseMeetingInfo(string joinURL)
var decodedURL = WebUtility.UrlDecode(joinURL);

//// URL being needs to be in this format.
/// https://gov.teams.microsoft.us/l/meetup-join/19:gcch:meeting_a58ee79c201f412a84a2cd5d80bf45bb@thread.v2/0?context={"Tid":"fef24bbe-18d9-453d-a4c9-3471d278af0c","Oid":"d7383a51-18d8-4fbf-b01f-f3c8c5bbe473"}
//// https://teams.microsoft.com/l/meetup-join/19:cd9ce3da56624fe69c9d7cd026f9126d@thread.skype/1509579179399?context={"Tid":"72f988bf-86f1-41af-91ab-2d7cd011db47","Oid":"550fae72-d251-43ec-868c-373732c2704f","MessageId":"1536978844957"}
//// https://teams.microsoft.com/l/meetup-join/19:meeting_MDQzYmJlMDctMWJiZS00OGExLTlmYjUtZTczNzVhZGM1OTQx@thread.v2/0?context={"Tid":"c80f38d3-c04c-49bf-a48b-9d99278d4ac6","Oid":"782f076f-f6f9-4bff-9673-ea1997283e9c"}

var regex = new Regex("https://teams\\.microsoft\\.com.*/(?<thread>[^/]+)/(?<message>[^/]+)\\?context=(?<context>{.*})");
var regex = new Regex("https://gov\\.teams\\.microsoft\\.us.*/(?<thread>[^/]+)/(?<message>[^/]+)\\?context=(?<context>{.*})");
var match = regex.Match(decodedURL);
if (!match.Success)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,23 @@ public Task HangUp(string id)
/// <inheritdoc/>
public Task InviteParticipant(string id, IEnumerable<IdentitySet> participants)
{
var invitationParticipants = participants.Select(participant =>
try {
var invitationParticipants = participants.Select(participant =>
new InvitationParticipantInfo
{
Identity = participant
});

return graphServiceClient.Communications.Calls[id].Participants
.Invite(invitationParticipants, id)
.Request()
.PostAsync();
return graphServiceClient.Communications.Calls[id].Participants
.Invite(invitationParticipants, id)
.Request()
.PostAsync();
}
catch (Exception e) {
Console.WriteLine(e);
return null;
}

}

/// <inheritdoc />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Graph;
using Microsoft.Graph.ExternalConnectors;

namespace CallingBotSample.Services.MicrosoftGraph
{
Expand All @@ -24,7 +23,7 @@ public Task<TeamsAppInstallation> InstallApp(string chatId, string teamsCatalogA
{
AdditionalData = new Dictionary<string, object>()
{
{"teamsApp@odata.bind", $"https://graph.microsoft.com/v1.0/appCatalogs/teamsApps/{teamsCatalogAppId}"}
{"teamsApp@odata.bind", $"https://graph.microsoft.us/v1.0/appCatalogs/teamsApps/{teamsCatalogAppId}"}
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
using System;
using Azure.Identity;
using CallingBotSample.Options;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Graph;
using Microsoft.Graph.Communications.Client.Authentication;
using Microsoft.Graph.Communications.Common;
using Microsoft.Extensions.DependencyInjection;

namespace CallingBotSample.Services.MicrosoftGraph
{
Expand All @@ -23,11 +25,14 @@ public static IServiceCollection AddMicrosoftGraphServices(this IServiceCollecti
var options = new AzureAdOptions();
azureAdOptionsAction(options);

ClientSecretCredential authenticationProvider = new ClientSecretCredential(options.TenantId, options.ClientId, options.ClientSecret);
//var options = new ClientSecretCredentialOptions { AuthorityHost = AzureAuthorityHosts.AzureGovernment, }; // https://learn.microsoft.com/dotnet/api/azure.identity.clientsecretcredentialvar clientSecretCredential = new ClientSecretCredential( tenantId, clientId, clientSecret, options);

ClientSecretCredential authenticationProvider = new ClientSecretCredential(options.TenantId, options.ClientId, options.ClientSecret, new ClientSecretCredentialOptions { AuthorityHost = AzureAuthorityHosts.AzureGovernment });

var authProvider = new TokenCredentialAuthProvider(authenticationProvider, new[] { "https://graph.microsoft.us/.default" } );
services.AddScoped<GraphServiceClient, GraphServiceClient>(sp =>
{
return new GraphServiceClient(authenticationProvider);
return new GraphServiceClient("https://graph.microsoft.us/v1.0", authProvider, null);
});

services.AddTransient<ICallService, CallService>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
"MicrosoftAppId": "<<microsoft-app-id>>",
"MicrosoftAppPassword": "<<microsoft-app-client-secret>>",
"AzureAd": {
"Instance": "https://login.microsoftonline.com/",
"Instance": "https://login.microsoftonline.us/",
"TenantId": "<<tenant-Id>>",
"ClientId": "<<MicrosoftAppId>>",
"ClientSecret": "<<MicrosoftAppPassword>>"
},
"Bot": {
"AppId": "<<microsoft-app-id>>",
"AppSecret": "<<microsoft-app-client-secret>>",
"PlaceCallEndpointUrl": "https://graph.microsoft.com/v1.0",
"PlaceCallEndpointUrl": "https://graph.microsoft.us/v1.0",
"BotBaseUrl": "https://<<subdomain>>.ngrok-free.app",
"GraphApiResourceUrl": "https://graph.microsoft.com",
"MicrosoftLoginUrl": "https://login.microsoftonline.com/",
"GraphApiResourceUrl": "https://graph.microsoft.us",
"MicrosoftLoginUrl": "https://login.microsoftonline.us/",
"RecordingDownloadDirectory": "temp",
"CatalogAppId": "<<teams-catalog-app-id>>"
},
Expand All @@ -25,5 +25,13 @@
},
"Users": {
"UserIdWithAssignedOnlineMeetingPolicy": "<<object-id-of-the-user-to-whom-online-meeting-policy-has-been-granted>>"
}
},
"ChannelService": "https://botframework.azure.us",
"OAuthUrl": "https://tokengcch.botframework.azure.us/",
"ToChannelFromBotLoginUrl": "https://login.microsoftonline.us/MicrosoftServices.onmicrosoft.us",
"ToChannelFromBotOAuthScope": "https://api.botframework.us",
"ToBotFromChannelTokenIssuer": "https://api.botframework.us",
"ToBotFromChannelOpenIdMetadataUrl": "https://login.botframework.azure.us/v1/.well-known/openidconfiguration",
"ToBotFromEmulatorOpenIdMetadataUrl": "https://login.microsoftonline.us/fef24bbe-18d9-453d-a4c9-3471d278af0c/v2.0/.well-known/openid-configuration",
"ValidateAuthority": true
}