NEED HELP WITH CODE in POO please :( 04-03-2023, 12:46 PM
#1
private async Task MakePhoneCallAsync(ITurnContext turnContext, CancellationToken cancellationToken, string phoneNumber)
{
// Authenticate with Microsoft Graph using the client credentials flow
string[] scopes = new string[] { "https://graph.microsoft.com/.default" };
var confidentialClientApplication = ConfidentialClientApplicationBuilder
.Create(_configuration["MicrosoftAppId"])
.WithClientSecret(_configuration["MicrosoftAppPassword"])
.WithAuthority($"https://login.microsoftonline.com/54f849a2-42a5-4304-84a4-34c99e642840")
.Build();
var authenticationResult = await confidentialClientApplication.AcquireTokenForClient(scopes).ExecuteAsync();
// Create the call
var graphClient = new GraphServiceClient(new DelegateAuthenticationProvider(async (requestMessage) =>
{
requestMessage.Headers.Authorization = new AuthenticationHeaderValue("Bearer", authenticationResult.AccessToken);
}));
try
{
var call = await graphClient.Communications.Calls.Request()
.AddAsync(new Call
{
Targets = new[]
{
new InvitationParticipantInfo
{
Identity = new IdentitySet
{
User = new Microsoft.Graph.Identity
{
Id = phoneNumber
}
}
}
},
MediaConfig = new ServiceHostedMediaConfig
{
PreFetchMedia = new[]
{
new MediaInfo { Uri = $"tel:{phoneNumber}" }
}
}
});
}
catch (ServiceException ex)
{
await turnContext.SendActivityAsync($"Error making call: {ex.Message}", cancellationToken: cancellationToken);
}
}
Error making call: Code: 7505
Message: Request authorization tenant mismatch.
Inner error:
AdditionalData:
date: 2023-04-03T11:02:17
request-id: f655b392-3acb-4e36-9ddc-6fcb68340dc6
client-request-id: f655b392-3acb-4e36-9ddc-6fcb68340dc6
ClientRequestId: f655b392-3acb-4e36-9ddc-6fcb68340dc6
BOT FOR TEAMS THAT MAKES CALLS FOR PHONES TROUGH MICROSOFT GRAPH API.
SO I WENT TO CHECK AND THE REASON FOR THE ERROR IS THAT THE TENANTID IS NOT VALID, BUT THIS IS THE SAME TENANT ID FROM MY AZURE BOT
{
// Authenticate with Microsoft Graph using the client credentials flow
string[] scopes = new string[] { "https://graph.microsoft.com/.default" };
var confidentialClientApplication = ConfidentialClientApplicationBuilder
.Create(_configuration["MicrosoftAppId"])
.WithClientSecret(_configuration["MicrosoftAppPassword"])
.WithAuthority($"https://login.microsoftonline.com/54f849a2-42a5-4304-84a4-34c99e642840")
.Build();
var authenticationResult = await confidentialClientApplication.AcquireTokenForClient(scopes).ExecuteAsync();
// Create the call
var graphClient = new GraphServiceClient(new DelegateAuthenticationProvider(async (requestMessage) =>
{
requestMessage.Headers.Authorization = new AuthenticationHeaderValue("Bearer", authenticationResult.AccessToken);
}));
try
{
var call = await graphClient.Communications.Calls.Request()
.AddAsync(new Call
{
Targets = new[]
{
new InvitationParticipantInfo
{
Identity = new IdentitySet
{
User = new Microsoft.Graph.Identity
{
Id = phoneNumber
}
}
}
},
MediaConfig = new ServiceHostedMediaConfig
{
PreFetchMedia = new[]
{
new MediaInfo { Uri = $"tel:{phoneNumber}" }
}
}
});
}
catch (ServiceException ex)
{
await turnContext.SendActivityAsync($"Error making call: {ex.Message}", cancellationToken: cancellationToken);
}
}
Error making call: Code: 7505
Message: Request authorization tenant mismatch.
Inner error:
AdditionalData:
date: 2023-04-03T11:02:17
request-id: f655b392-3acb-4e36-9ddc-6fcb68340dc6
client-request-id: f655b392-3acb-4e36-9ddc-6fcb68340dc6
ClientRequestId: f655b392-3acb-4e36-9ddc-6fcb68340dc6
BOT FOR TEAMS THAT MAKES CALLS FOR PHONES TROUGH MICROSOFT GRAPH API.
SO I WENT TO CHECK AND THE REASON FOR THE ERROR IS THAT THE TENANTID IS NOT VALID, BUT THIS IS THE SAME TENANT ID FROM MY AZURE BOT




![[+]](https://sinister.li/images/modern/collapse_collapsed.png)