Azure Bot返回的令牌是什么? [英] What is the token returned by the Azure Bot?
问题描述
I followed this tutorial to setup authentication for my Azure Bot. After a successful login, it returns a token for me. I believe that this is an authorization token to access the Microsoft Graph API. If I wanted to use this same token to exchange for an access token to another web application, is that possible? And how would I be able to do it?
推荐答案
是的,是possilbe.
Yes, it's possilbe.
授权完成后,您应该可以获取refresh_token.
You should be able to get a refresh_token after the authorization is finished.
使用此refresh_token与另一个Web应用程序的scope
交换另一个access_token.像这样:
Use this refresh_token to exchange another access_token with the scope
of another web application. Like this:
然后我们可以获取另一个作用域的access_token:
Then we can get an access_token for another scope:
您可以看到范围已从https://graph.microsoft.com
更改为api://{id}/user.write
,这是另一个Web API.
You can see that the scope has changed from https://graph.microsoft.com
to api://{id}/user.write
which is another web API.
更新:
也许我有一个误会,因为我看到你想交换一个新的访问令牌.
Maybe I have a misunderstanding because I see you want to exchange a new access token.
如果您只想从Bot应用程序访问自己的Web api,而无需调用Microsoft Graph API,只需修改资源URL (Azure AD v1)或 Scopes (Azure AD v2).无需交换新的访问令牌.
If you just want to access your own web api from Bot application and don't need to call Microsoft Graph API, just modify the Resource URL (Azure AD v1) or Scopes (Azure AD v2). It's unnecessary to exchange a new access token.
For Azure AD v1, you should set Resource URL as: api://{api id}
.
For Azure AD v2, set Scopes as: api://{api id}/.default
.
请注意,api://{api id}
是您的网络API.
Please note that api://{api id}
is your web api.
这篇关于Azure Bot返回的令牌是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!