502 badgateway with response 401 status code - Issue only when Auth for App service turned on
We have an app-service default.htm page to which we are loading the chat bot using direct-line keys. PFB code used for same in default.html scripts.
BotChat.App({ bot: bot, locale: params['locale'], resize: 'detect', // sendTyping: true, // defaults to false. set to true to send 'typing' activities to bot (and other users) when user is typing speechOptions: speechOptions, user: user, directLine: { domain: params['domain'], secret: key, // token: params['t'], webSocket: params['webSocket'] && params['webSocket'] === 'false' // defaults to true } }, document.getElementById('chatbotdiv'));
When the host app-service authentication is set to anonymous, The bot works fine when accessing the app-service url, we can see the chat window with results.
However when we are turning on the authentication to Login via AD for the app service, the bot is no longer working. Getting a 502 error in console and upon inspecting response can see 401 unauthorized. Kindly suggest!! Everything works fine when we remove the authentication option on Appservice, but we can't do that since we require the site to be protected.
Botbuilder versions tried: 3.15.2 & 3.17.0.42969
[BotAuthentication] attribute provided. Web config contains values for
Hi @GayathriR2018, the issue is that the webpage and bot's endpoint are on the same service. When you enable AAD authentication to protect the webpage, it's enabling AAD auth for the bot's endpoint as well. This won't work because the service-to-service auth used to protect the endpoint is different from user authentication.
To enable AAD authentication on your website, you will need to move your bot's endpoint so it's not affected by this setting.