I create a microsoft teams app using App studio and added a bot to it. I am using the sample code provided for the bot here https://github.com/microsoft/BotBuilder-Samples/tree/master/samples/python/46.teams-auth. However the sample required a ConnectionName setting in config.py. But I do not see a OAuthsetting section in the created bot. How can this config be set.
You can add the authentication setting in Azure portal Bot Channels Registration.
Setting -> Add Setting
You could follow this document for adding authentication to bot
Related
Half a year ago we created a bot using the App Studio app from Teams. This worked well and the bot is running happily. Apparently starting 2022 App Studio "evolved":
So, this time using the new "evolved" Developer Portal, we registered a similar bot in another environment.
Just to end up with a bot that somehow is not registered in the Microsoft-internal bot framework tenant. I cannot say how we ended up in this state but there is a troubleshooting site that we can use to verify our failed state. The result of this simple call looks like this:
For googleability:
AADSTS700016: Application with identifier
'68dafaa0-5755-4433-8f47-3e174c5ed131' was not found in the directory
'Bot Framework'. This can happen if the application has not been
installed by the administrator of the tenant or consented to by any
user in the tenant. You may have sent your authentication request to
the wrong tenant.
Now the question: how can we add our bot to this "Bot Framework" tenant? And: which of the button clicks in the Dev Center and/or Bot Framework portal do the magic of adding the bot? The troubleshooting article unfortunately gives no advice on how to fix this situation.
We also tried removing the bot via the Bot Framework portal and re-created it with the same IDs and had the hope this fixes the situation. Unfortunately not.
Note: everything else is in place and looks like our other functioning bot. A teams app containing the bot, the Azure AD app registration with the bot ID, the bot in the bot portal, correct client secret. Everything seems correct except that the bot ID is missing from the Bot Framework tenant.
Just ran into the same issue. It looks like you have your bot registered into your tenant (and not the global bot framework). So you can get the access token by changing the URL to the following (replacing with your tenant id):
https://login.microsoftonline.com/YOUR-TENANT-ID/oauth2/v2.0/token
Just tested this and was able to get an access token. Now will that token actually work the same way using the scope is another matter. You may need to change the scope to:
https://graph.microsoft.com/.default
As of now I am getting a token either way
To generate a bot directly into the global tenant you can go to the following URL and click on "My Bots" and then "Create". Any existing bots you have should also appear here:
https://dev.botframework.com/
I have an existing bot code that uses OAuthPrompt dialog that I would like to deploy for Zoom and WebEx that are not supported by Azure Bot Service. As per the documentation and sample code, I have used the adapter for supporting those channels. It works fine. But it does not support OAuthPrompt Dialog, it returns "OAuthPrompt.BeginDialog(): not supported by the current adapter".
When I debugged with the source code (Bot builder SDK /w Adapter), Implementation of OAuthPrompt dialog checks whether adapter implements IExtendedUserTokenProvider interface, currently it is not, so it returns error. How to add OAuth card support without using OAuthPrompt Dialog/Azure Bot Service?
This question is similar to mine:
(Is there any way to use authentication service without azure bot service?)
Following are my thoughts:
Directly send a request to identity provider with redirect URL (my bot endpoint) for OAuth2 code flow. Also update the redirect URI in the App Registration portal with bot endpoint, currently I have provided Redirect URI as "https://token.botframework.com/.auth/web/redirect" for supported channels.
Implement the IExtendedUserTokenProvider in the adapter (similar to Emulator).
Any feedback is appreciated.
I can get it working by having customized OAuthPrompt dialog for Zoom, implementing IExtendedUserTokenProvider in ZoomAdapter (ZoomAdapterWIthErrorHandler). OAuth connection settings (such as identity server endpoint, scopes, redirect uri} are stored in the appSettings.json for the connection name. Supported channels (MS Teams and Slack) will use the SDK provided implementation (OAuthPrompt Dialog) with settings from ConnectionName configured in the Azure, unsupported channels will get the settings from the AppSettings.json file. GetSignInResourceAsync() should have the right implementation that returns the sign-in resource Uri.
I have the HelloWorld app sample running (browser launches: http://localhost:3333/)
In Bot Framework Emulator, I open a Bot (http://localhost:3333/api/messages) and connect.
I write a message and I see:
Cannot post activity. Unauthorized.
POST 401 directline.postActivity
I have tried with and without ngrok, but I suppose that is not the problem.
What can be wrong?
Thanks,
Diego
I got it. Once I saw that Emulator requires empty 'Appid' and 'PasswordId' values (appsettings.json), I tried to get my BOT running in Teams client.
Now I have my application running locally and a Bot created in Teams client which can interact with it using a ngrok redirection
The key was to create the bot from Team client (not in dev.botframework.com/bots) logged with the same user than in Azure portal, and using App Studio.
Then an app is automatically created in Azure portal (NewApp).
Important:
App Id in appsettings.json is the one created from App Studio Bots option. It is also in Azure portal: App registrations-NewApp-'Application (client) ID'. And also twice in botframework (NewBot Settings: 'Bot handle' and 'Configuration'-'Paste your appId below...')
In App Studio 'app creation' there is another 'App ID' in App Details. It is not required to be the same.
App password in appsettings.json is the one created in App Studio (App Password -> Generate). It is also in in Azure portal: App registrations-NewApp-Certificates&secrets/Client secrets
ngrok url must be added in App Studio bot (Messaging endpoint: 'https://xxxxxx.ngrok.io'). It is also in botframework (NewBot Settings-Messaging endpoint)
I want to try the demo on Add authentication to your bot via Azure Bot Service which based on the document https://learn.microsoft.com/en-us/azure/bot-service/bot-builder-tutorial-authentication?view=azure-bot-service-3.0, what i am using is Demonstrates OAuthCard support in the v3 C# SDK, using AAD v2, but i always failed when i use bot emulator to connect the bot service.
i think i set the correct the settings in the webconfig.
I am trying to register my Bot at https://dev.botframework.com
However, when I put https://localhost:44338/api/messages in the
Messaging endpoint field I get an error - Endpoint URL has an invalid
value. My bot is running locally on https://localhost:44338.
Also is there any way I can create my own web client which can
communicate with my Bot.
Is Bot Registration mandatory for it to be deployed in production.
It looks like you're trying to register your bot with your local instance whereas you need to use a deployed (production) instance.
Publish your bot to Azure and use the URL you get from that. In Visual Studio you can right click your project and select "Publish"- just follow the instructions from there.
You can make your own client, yes. You can use your browser or anything else to make HTTP requests to your production bot.
You need to register your bot if you're using the bot connector.
Hope that helps.