botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

[Skype For Business, Question] How to get Authentication token of a User interacting with Bot over Skype for Business channel?

Open GauravDhavale opened this issue 9 years ago • 13 comments

Bot Info

  • Bot handle:
  • App ID: 2489776e-b4a1-4d55-b2ba-c430142c75fe
  • SDK Platform: Node.js
  • SDK Version: "botbuilder": "^3.9.0", Node.js: 6.11.0
  • Active Channels: Skype for Business
  • Deployment Environment: Azure App Service

Question Description

I have created a Bot in Node JS using Microsft Bot Framework and is deployed on Skype for Business (SFB) channel.

Whenever a user interacts with Bot over SFB and asks to fetch some details, I want the Bot to get these details from my companies internal system using the user's authentication token which should have generated when user login to SFB.

So, is there any way to get user's token from SFB which the Bot can use to get the required information on user's behalf? My companies internal system, SFB uses the same Azure AD for user authentication.

Asking the user to authenticate every time he/she ask a question won't be a good for user experience as the user has already been authenticated over SFB.

Can someone please help me with some documentation that I can refer to resolve this issue?

GauravDhavale avatar Sep 25 '17 17:09 GauravDhavale

@GauravDhavale I'm interested on that too. Do you have any news on that? I'm following this guide here but I agree with you on the fact that this is not good for user experience.

papaioannous avatar Oct 19 '17 13:10 papaioannous

@GauravDhavale you can get the user-id where you can expect result as sip:[email protected] hope that helps you and authentication is not needed over here as user is already pre-authenticated when logging into skype for business Bot is built using node.js

ShujaathKhan avatar Oct 22 '17 09:10 ShujaathKhan

@ShujaathKhan I understand that the user is already authenticated. Let's say, I have a use-case where the user asks Bot to check his/her email over the channel SFB. Now, in this case, user-id won't be sufficient for the Bot to fulfill this request. The Bot must have user's access token to perform this request on the user's behalf.

@papaioannous You can refer this for info.

GauravDhavale avatar Oct 23 '17 00:10 GauravDhavale

@GauravDhavale you can provide admin consent which is newly released in botframework where you can read mail calendar and other graph content. I have not tried it so but, have seen them.

ShujaathKhan avatar Oct 25 '17 11:10 ShujaathKhan

@ShujaathKhan Thanks for sharing this information. Let me revise my use-case. We have web applications in the company where the user must log in to access specific information. Now my use-case is when the user asks some information over SfB channel of Bot, the Bot need to send that request to these web applications on user's behalf. I guess in this scenario, I must send the user's access token along with request object to these web applications. Do you think this email account will help me in this scenario?
Thanks

GauravDhavale avatar Oct 25 '17 14:10 GauravDhavale

How to do this in the C# SDK ?

We need to allow skype for business users to schedule meetings in their name while talking to the bot.

AndreMantas avatar Feb 23 '18 10:02 AndreMantas

@AndreMantas You can use the graph api for the outlook calendar https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/resources/calendar. In the "Activity" object there is the "From" property which contains the "Id" - which is the skype email address, use that. Also i think you will need to register a new app in azure https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-integrating-applications and give Active Directory permissions for creating calendar events with the email address that you obtained from skype. Hope this helps.

papaioannous avatar Feb 26 '18 16:02 papaioannous

Has anyone solved that issue? We are facing the same problem.

bora89 avatar Mar 22 '18 09:03 bora89

Has anyone have the solution, As the user is already logged in skype for business, is there any way of getting the access token.

satyansh-sagar avatar Aug 06 '18 05:08 satyansh-sagar

@GauravDhavale Did you found a solution for getting the access token directly in SFB?

satyansh-sagar avatar Aug 06 '18 05:08 satyansh-sagar

I got below response on the Stack

"When a user logs into SfB, the user is authenticated to use the SfB client with those credentials. The SIP URI (email address) of that user is sent to the Bot as part of the message. The Bot can access the Graph API on AAD to determine if the user's account has permission to access the resource. The user's token will not be available, but if the user has permission, and the Bot has enough permission, the Bot can retrieve that information on the user's behalf. This is not the same as the user himself obtaining the information. It's an admin were performing an action on behalf of a user. "

I didn't find a way to get the token yet.

GauravDhavale avatar Aug 09 '18 20:08 GauravDhavale

@GauravDhavale Thanks Gaurav. Have you done this as you explained above? If yes can you please share me the source code/steps to do this.

satyansh-sagar avatar Aug 10 '18 05:08 satyansh-sagar

Thank you for opening an issue against the Bot Framework SDK v3. As part of the Bot Framework v4 release, we’ve moved all v3 work to a new repo located at https://github.com/microsoft/botbuilder-v3. We will continue to support and offer maintenance updates to v3 via this new repo.

From now on, https://github.com/microsoft/botbuilder repo will be used as hub, with pointers to all the different SDK languages, tools and samples repos.

As part of this restructuring, we are closing all tickets in this repo.

For defects or feature requests, please create a new issue in the new Bot Framework v3 repo found here: https://github.com/microsoft/botbuilder-v3/issues

For Azure Bot Service Channel specific defects or feature requests (e.g. Facebook, Twilio, Teams, Slack, etc.), please create a new issue in the new Bot Framework Channel repo found here: https://github.com/microsoft/botframework-services/issues

For product behavior, how-to, or general understanding questions, please use Stackoverflow. https://stackoverflow.com/search?q=bot+framework

Thank you.

The Bot Framework Team

sgellock avatar Oct 02 '18 01:10 sgellock