[英]How do I authenticate to SharePoint in Bot Framework using logged in user?
I'm working on a bot running on MS Teams. 我正在研究在MS Teams上运行的机器人。
I'm trying to get logged in user information and use it to authenticate to SharePoint API, but without luck so far. 我正在尝试登录用户信息,并使用它来对SharePoint API进行身份验证,但到目前为止还算不上成功。
I'm using the controller from the following example: https://github.com/stephaneey/transparent-auth-bot/blob/master/transparent-auth-bot/Controllers/MessagesController.cs#L64 我正在使用以下示例中的控制器: https : //github.com/stephaneey/transparent-auth-bot/blob/master/transparent-auth-bot/Controllers/MessagesController.cs#L64
But I'm unable to get the token (line 64), it remains null/ 但是我无法获得令牌(第64行),它仍然为null /
The sample you are providing is demonstating the ability to get a Graph API token and reuse it in a Bot. 您提供的示例正在演示获取Graph API令牌并在Bot中重用它的能力。
As you can see here , this token is generated during a specific authentication process: there is a website displaying a webchat, and when you want to access it you have to login. 正如您在此处看到的那样,此令牌是在特定的身份验证过程中生成的:存在一个显示网聊的网站,当您要访问它时,必须登录。 That's where the value of the
"GraphAccessToken"
is generated and stored in a BotData object, which can be accessed from the code of the bot. 在那里,将生成
"GraphAccessToken"
的值并将其存储在BotData对象中,该对象可以从漫游器的代码进行访问。
Here if you use MS Teams you never asked the user to login, so there is no magic: the value will be null. 在这里,如果您使用MS Teams,则从未要求用户登录,因此没有任何魔力:该值将为null。
In a few words, if your target channel is Teams, you will not be able to automatically get an user token which you can use to query SharePoint API: you have to go through a manual login process. 简而言之,如果您的目标渠道是Teams,则将无法自动获取可用于查询SharePoint API的用户令牌:您必须执行手动登录过程。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.