Unauthorized error in User authentication in Bot in Government Cloud(GCC High)

Pavan Kumar 1 Reputation point
2022-07-01T05:21:23.923+00:00

I am getting Unauthorized error, bot setup details are given below. I have tried the same setup in commercial azure and it's working. Issue is only in GCC High Azure.

bot Setup in Azure portal (portal.azure.us)

  • Created Azure Bot in Azure portal.
  • Add new client secret in Bot Azure App.
  • Added redirect URI in authentication settings "https://tokengcch.botframework.azure.us/.auth/web/redirect"
  • In Bot configuration in Azure portal
  • Configured Messaging endpoint
  • Created oAuth connection setting - Test Connection is working.

Used TeamsAuth Sample code.

  • Updated AppSettings.json file.
  • MicrosoftAppId
  • MicrosoftAppPassword
  • ConnectionName
  • Added this code in startup.cs file as per this Article. (tried this and without this code also)
    string uri = "https://apiGCCH.botframework.azure.us"; MicrosoftAppCredentials.TrustServiceUrl(uri); AuthClientConfig.OAuthEndpoint = uri;

I have tried the bot in Teams and Web chat Channels. getting below excetion in both

Exception Message: Microsoft.Rest.HttpOperationException: Operation returned an invalid status code 'Unauthorized' at Microsoft.Bot.Connector.OAuthClient.GetSignInResourceWithHttpMessagesAsync(String state, String codeChallenge, String emulatorUrl, String finalRedirect, Dictionary2 customHeaders, CancellationToken cancellationToken) at Microsoft.Bot.Connector.BotSignInExtensions.GetSignInResourceAsync(OAuthClient operations, String state, String codeChallenge, String emulatorUrl, String finalRedirect, CancellationToken cancellationToken) at Microsoft.Bot.Connector.Authentication.UserTokenClientImpl.GetSignInResourceAsync(String connectionName, Activity activity, String finalRedirect, CancellationToken cancellationToken) at Microsoft.Bot.Builder.Dialogs.UserTokenAccess.GetSignInResourceAsync(ITurnContext turnContext, OAuthPromptSettings settings, CancellationToken cancellationToken) at Microsoft.Bot.Builder.Dialogs.OAuthPrompt.SendOAuthCardAsync(OAuthPromptSettings settings, ITurnContext turnContext, IMessageActivity prompt, CancellationToken cancellationToken) at Microsoft.Bot.Builder.Dialogs.OAuthPrompt.BeginDialogAsync(DialogContext dc, Object options, CancellationToken cancellationToken) at Microsoft.Bot.Builder.Dialogs.DialogContext.BeginDialogAsync(String dialogId, Object options, CancellationToken cancellationToken) at Microsoft.BotBuilderSamples.MainDialog.PromptStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) in D:\Bot\46.teams-auth\Dialogs\MainDialog.cs:line 51 at Microsoft.Bot.Builder.Dialogs.WaterfallDialog.OnStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) at Microsoft.Bot.Builder.Dialogs.WaterfallDialog.RunStepAsync(DialogContext dc, Int32 index, DialogReason reason, Object result, CancellationToken cancellationToken) at Microsoft.Bot.Builder.Dialogs.WaterfallDialog.BeginDialogAsync(DialogContext dc, Object options, CancellationToken cancellationToken) at Microsoft.Bot.Builder.Dialogs.DialogContext.BeginDialogAsync(String dialogId, Object options, CancellationToken cancellationToken)

Microsoft Teams
Microsoft Teams
A Microsoft customizable chat-based workspace.
10,895 questions
Microsoft Teams Development
Microsoft Teams Development
Microsoft Teams: A Microsoft customizable chat-based workspace.Development: The process of researching, productizing, and refining new or existing technologies.
3,705 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
23,785 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.