botbuilder-js: [OAuthPrompt] The call to https://api.botframework.com/api/usertoken/GetToken returns a 500 response

Versions

4.16

Describe the bug

When using the OAuthPrompt Dialog from the SDK, the call to https://api.botframework.com/api/usertoken/GetToken performed by the SDK returns a 500 status error response. According to the code, the SDK awaits either a 200 or 404 status.

To Reproduce

Steps to reproduce the behavior:

I tried to follow this guide in order to add authentication to the bot with my own identity provider:

https://learn.microsoft.com/en-us/azure/bot-service/bot-builder-authentication?view=azure-bot-service-4.0&tabs=userassigned%2Caadv2%2Ccsharp

  1. Configure a custom identity provider on Azure
  2. Configure the bot with the identity provider connection name
  3. Type anything
  4. Auth Prompt should appear but nothing happens
  5. I receive a 500 status code in the response
  6. The bot console displays the following error:
      body: '{\r\n' +
        '  "error": {\r\n' +
        '    "code": "ServiceError",\r\n' +
        '    "message": "Error retrieving token: caeb276526109146868df38d74c9c52a."\r\n' +
        '  }\r\n' +
        '}',

Expected behavior

Auth Prompt should display a sign-in button

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 17
  • Comments: 17 (9 by maintainers)

Most upvoted comments

Hi @elacallefactorial, thanks for your patience.

Looks like there may be additional configurations needed for West Europe region.

Could you please provide below additional configuration in .env file and try again to see if that fixes this authentication issue:

BotOpenIdMetadata=https://login.botframework.com/v1/.well-known/openidconfiguration
ValidateAuthority=true
ToChannelFromBotLoginUrl=https://login.microsoftonline.com/botframework.com
ToChannelFromBotOAuthScope=https://api.botframework.com
ToBotFromChannelTokenIssuer=https://api.botframework.com
OAuthApiEndpoint=https://europe.api.botframework.com
ToBotFromChannelOpenIdMetadataUrl=https://login.botframework.com/v1/.well-known/openidconfiguration
ToBotFromEmulatorOpenIdMetadataUrl=https://login.microsoftonline.com/botframework.com/v2.0/.well-known/openid-configuration
CallerId=urn:botframework:azure

Example: image

Let me know if you have any questions. Thanks.