This happens because the Bot Framework's OAuth flow expects the bot to handle the validation code and exchange it for an access token.
Solution:
a. Implement a handler for the "signin/tokenExchange" activity in your bot:
if (activity.name === 'signin/tokenExchange') {
// Handle token exchange here
}
b. In this handler, use the validation code to request an access token from your OAuth provider.
c. Once you have the access token, store it securely and associate it with the user.
d. Send a message back to the user confirming successful authentication.
You need to implement this token exchange logic on your bot's backend. The token.botframework.com
page is not meant to be interacted with directly by the user.
More:
https://learn.microsoft.com/en-us/azure/bot-service/bot-builder-authentication?tabs=userassigned%2Caadv1%2Ccsharp&view=azure-bot-service-4.0
https://learn.microsoft.com/en-us/microsoftteams/platform/bots/how-to/authentication/add-authentication?tabs=dotnet%2Cdotnet-sample