microsoft / botbuilder-js

Welcome to the Bot Framework SDK for JavaScript repository, which is the home for the libraries and packages that enable developers to build sophisticated bot applications using JavaScript.
https://github.com/Microsoft/botframework
MIT License
679 stars 276 forks source link

JwtTokenExtractor.getIdentity:err! https://Telegram.enterprisechannel.botframework.com/v1/.well-known/openidconfiguration #1530

Closed pagex closed 4 years ago

pagex commented 4 years ago

Versions

all is latest

Describe the bug

Creating bot framework adapter, in config set ChannelService=Telegram tried to post to jwtTokenExtractor.ts tries to post to "https://Telegram.enterprisechannel.botframework.com/v1/.well-known/openidconfiguration" which fails with not found as url probably does not exist then JwtTokenExtractor.getIdentity:err!

To Reproduce

// Create adapter. const adapter = new BotFrameworkAdapter({ appId: process.env.MicrosoftAppId, appPassword: process.env.MicrosoftAppPassword, channelService: process.env.ChannelService, openIdMetadata: process.env.BotOpenIdMetadata }); set channel service to Telegram

Additional context

Using ngrok and local instance, note if ChannelService is left empty all works fine as url generated will be https://login.enterprisechannel.botframework.com/v1/.well-known/openidconfiguration

Why do we need this ChannelService if it does not work?

v-kydela commented 4 years ago

Hello @pagex

You can see in the source code that any channel service that's not public Azure or government Azure is interpreted as Enterprise Channel Validation. That means your channel service is used to form this URL:

export const ToBotFromEnterpriseChannelOpenIdMetadataUrlFormat =
    'https://{channelService}.enterprisechannel.botframework.com/v1/.well-known/openidconfiguration';

I think you may be misunderstanding the purpose of the channel service configuration. What are you trying to accomplish? Are you just trying to build a bot for the Telegram channel?

v-kydela commented 4 years ago

@pagex - Are you still working on this?

cleemullins commented 4 years ago

@pagex - please let us know if @v-kydela's explanation made sense. I'll close this out at the end of the week, if we don't hear back.

pagex commented 4 years ago

Thanks all for responses, I was under impression that ChannelService suppose to be set to channel I build bot for e.g. Skype or Telegram. I can't find online valid options for ChannelService though. Yes I built a telegram bot that works fine now when ChannelService is not set or set to empty. But some explanation when and how to use it would be much appreciated.

v-kydela commented 4 years ago

@pagex - The idea behind the Bot Framework is that you can build one bot that works on many different channels without having to alter the code for each one. It doesn't make any sense to want to configure your bot so that it only works with a specific channel. Each activity your bot receives will contain information about the channel it's communicating with in the activity's channelId and serviceUrl properties, and if you want you can write channel-specific code based on the activity's channel ID.

When you come across a feature that you don't understand like BotFrameworkAdapterSettings.channelService, it's probably best not to use it until you figure out what it's for. The optional channelService property is an advanced feature not for configuring what channel the bot uses but rather for configuring the service that the bot uses to access channels. If you leave it alone then your bot will use the ordinary Azure Bot Service or "public Azure," but if you set it to https://botframework.azure.us (found here) then that configures the bot to use government Azure. In your case you don't have to worry about channelService.

I was under impression that ChannelService suppose to be set to channel I build bot for e.g. Skype or Telegram.

Who told you this? Was there some tutorial you were following that told you to use the channelService property? Why did you want to use it?

pagex commented 4 years ago

Thanks @v-kydela, from my initial search I was unable to clearly understand what range of options this parameter takes that lead me to do some guesswork. Now its clear.

v-kydela commented 4 years ago

@pagex - I'm happy we could get this resolved. Please feel free to ask any more questions you might have on Stack Overflow or use this repo to post bug reports and feature requests.