Azure-Samples / Azure-Samples/communication-services-dotnet-quickstarts

Cognitive Services authentication issue with CallAutomation_MCS_Sample

Open
#201 12 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
114
Forks
145
PR merge metrics
No merged PRs in 30d

Description

Hello.

I am playing around with the CallAutomation_MCS_Sample and I am able to get most things working. The call to the ACS number is answered and I can see in the debug logging that integration with my Copilot Studio Agent is happening. However, there is no audio played back, and I receive this error:

Event received: {"ReasonCode":{},"FailedPlaySourceIndex":0,"CallConnectionId":"XXXXX","ServerCallId":"XXXXX","CorrelationId":"XXXXX","OperationContext":"Testing","ResultInformation":{"Code":401,"SubCode":8565,"Message":"Action failed due to a Cognitive Services authentication error. Please check your authorization input and ensure it is correct."}}

I did add this code to pull the Cognitive Services API key from appsettings.json and set it in the header:

//Get the Cognitive Services endpoint from appsettings.json
var cognitiveServicesEndpoint = builder.Configuration.GetValue("CognitiveServiceEndpoint");
ArgumentNullException.ThrowIfNullOrEmpty(cognitiveServicesEndpoint);

// Retrieve Cognitive Services API key from appsettings.json
var cognitiveServicesKey = builder.Configuration.GetValue("CognitiveServiceKey");
ArgumentNullException.ThrowIfNullOrEmpty(cognitiveServicesKey);

// Create an HTTP client for Cognitive Services
HttpClient cognitiveServicesClient = new HttpClient
{
BaseAddress = new Uri(cognitiveServicesEndpoint) // Set the base address
};
// Add the the Key for the Authentination Header
cognitiveServicesClient.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", cognitiveServicesKey);

But that did not make a difference. Is there something else that I am missing?

Pinging @ypradhan-msft for input.

Files:

[appsettings.json](https://github.com/user-attachments/files/20208742/appsettings.json)

[Program1.txt](https://github.com/user-attachments/files/20208769/Program1.txt)

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the attached appsettings.json and Program1.txt, then trace how CallAutomation_MCS_Sample configures Cognitive Services authentication for the audio operation. Reproduce the reported 401 authentication error and confirm completion when the call plays audio without that error.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp
Domain
api, authentication, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.