MTeams bot authorization (OAuth, get/use/refresh token) to my web service - microsoft-teams

Could you help me to implement login functionality to my web application (OAuth)?
I created MS teams bot and need to connect to my web service. I need to call (from the bot) my login web page (Login page: user & pass), get token and then use (refresh if needed) the token to make API requests (from bot) to my service.
Examples, architecture, suggestions?
Thank you ...
How to authenticate a user using a teams bot using my own custom authentication service?
https://github.com/microsoft/BotBuilder-Samples/tree/main/samples/csharp_dotnetcore/46.teams-auth
I found some solution and ... Any different suggestions?
Also ... A question ... How can I override the existing dialog (the example) and use my content (new dialog body)?

You can take a look at Adding Authentication to your Teams Bot. Invoke activity is send to the Bot when user to click on oAuthPrompt Dialog. We have TeamsAuth sample code using the same oAuthPrompt dialog, You can set the oAuth setting for your Bot in Azure and test it. For more information how Authentication flow works in Teams Bot you can check the MS Teams Authentication flow in Bots, Bot uses the Dialog from TeamsActivityHandler class, You can create your own dialog using the same.

Related

How to perform Teams Channel Authentication for bot framework?

I am working on team's bot that is scoped to teams' channel and group chat. I am using a external service that is being used by the bot. Now if I add the bot to channel or group chat, i want a way to only authorize certain group of users or use their auth token to access the external service within bot. In a personal chat as given by the example 46. (link: https://github.com/microsoft/BotBuilder-Samples/tree/main/samples/python/46.teams-auth) Teams auth in Bot framework samples, we can do auth when we click sign in and the user gets to login then pass the token to the bot. How to perform the same action (bit less intrusive) in a channel or a group chat?

How to use Google Oauth2.0 to authenticate user via Telegram Bot

This is my first time interacting with Google API and I'm using python3.9 with this library Python Telegram Bot
I want to access a user Google API Calendar via a telegram bot and I can't seem to find any article to guide me through it. My key problem (I think) is redirecting the success authorization flow back to telegram bot.
This is what I have in mind:
In the telegram app, user send '/send' to bot
Bot receive message and return a google an authorization link to user
User clink on authorization link and allow access
Bot receive authorization access and completes the Oauth flow
The problem lies betweeen step 3 and 4. A standard authorization link is
https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=<clientid>&redirect_uri=<redirect_uri>&scope=<scope>&state<state>&access_type=offline
How do I send the authorization link back to my telegram bot? Should I create another API endpoint to receive that authorization link? Or can I send telegram api send_message() in the <redirect_uri> to redirect the success message to my bot.
Update 1
Thanks to CallMeStag, I manage to figure out a way to complete the oauth process. For people who faced the same problem, this is what I did
Pre-requisite: Credentials is created in google console api - Web application. redirect_uri set as localhost:8000 (During development phase)
User send '/send' to bot
Bot receive message and return an authorization link https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=<clientid>&redirect_uri=http://localhost:8000/&scope=<scope>&state<state>&access_type=offline
User click on link to authenticate and it will redirect to http://localhost:8000. Used fastapi as a webhook to receive the message. Capture the authorization code, use google.oauthlib.flow to complete the authorization process. Next, redirect user back to telegram link https://t.me/<botname>
Start using user google calendar
It's currently indeed not very straight forward for a PTB-application to listen for external updates (the auth verification in this cas) - see also this issue. Currently it might be easiest for you to set up a custom webhook application that runs in parallel to the Updater - e.g. using flask/django/starlette/fastapi/…. Alternatively, if you're using webhooks for your bot anyway, you can patch the Updater to do the job for you. Although that requires some manual work - see here for an example.
Once you are able to listen to updates coming from Google, handling them can be done via PTBs usual handler setup, specifically via the TypeHandler or even a custom Handler subclass - see this FAQ entry.
Regarding the redirect url: You'll want to redirect your user back to your bot, so you'll have to provide a link that does that. Bot.link should probably do the trick.
Disclaimer: I'm currently the maintainer of python-telegram-bot.

Skype Channel: Unable to login with 'Sign in' to save your chat

I have enabled Skype channel for my bot which on top of chat window shows option to login. I am unable to login using my work ID, rather I could login with my personal Microsoft account.
I could not find much documentation on this. How can I enable bot so that bot users can login only with their work email id?
This is the expected behavior as Skype doesn't let you create an account anymore with a business email address. If you want to test your bot by connecting it to Skype channel, then you can use your personal account. The Skype for Business channel is specifically designed for the usage of work email ID but it is being deprecated on the Bot Framework. I would suggest you to connect the bot to Microsoft Teams to login using work email ID.

Facebook Messaging API login permissions

What are Item for simple chat bot developed Facebook messaging API? My app just respond to the text message send by a Facebook user. I want to make my chatbot public but Facebook requires to add some items (permissions). Could you please help me out
You need manage_pages and pages_messaging permissions. You also need to submit your bot for approval in the 'Messenger' tab of your app console.

Creating a chat connector for communicating with the Bot Framework Service

I am trying to implement a bot in my website using the botbuilder framework for node.js. The function builder.ChatConnector() get the parameters appId and appPassword, does any one knows where can i found these appId and appPassword? It isn't clear for me in the microsoft documentation. The function is shown above:
function builder.ChatConnect
BotFramework documentation
You can find this information when you create your bot in Azure Bot Service, or when you proceed to register your bot at the dev portal.
Here's a brief walkthrough for registering through the dev portal with the minimum requirements. You'll need to fill out the name, bot handle and description for the bot as indicated below:
After this, you can scroll down and click on the button that says "Create Microsoft App ID and password".
Once you click on the button you'll be taken to a page with your bot name, your newly-generated App ID, and another button that allows you "Generate a password to continue".
After you click the button a small window will pop up with your password which you need to keep track of as it is only shown once!
NOTE: For developing and testing using the Emulator, you don't need this information just yet. You only need the AppID and password when you are making your bot public facing/deploying it.
You need to register your bot in https://dev.botframework.com/ and there you will get those values. Check this article that explains how to do that.

Resources