【发布时间】:2017-01-14 04:53:03
【问题描述】:
我的共享点网站上有一个列表,以及一个用于获取列表的 API url。
我基于我创建的机器人创建了一个 azure 目录应用程序,并为其提供了共享点权限和委派。
在我的机器人中,我使用adal-node 通过 clientId/clientSecret 获取令牌。返回的响应看起来像
{
tokenType: 'Bearer',
expiresIn: 3599,
expiresOn: Tue Sep 06 2016 17:26:19 GMT+0000 (Coordinated Universal Time),
resource: 'spn:00000002-0000-0000-c000-000000000000',
accessToken: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJS....d0fWNHCxdWjyRnrUBV-jks47XRzmeO...9IP-6DXknubwj6ui2v...e9LCgs_ZUZiMXmg',
isMRRT: true,
_clientId: '<clientID>',
_authority: 'https://login.microsoftonline.com/<AppID>/oauth2/authorize/<tenantName>'
}
我像这样将令牌传递到标题中
var options =
{
method: 'GET',
url: "https://uccentric-my.sharepoint.com/personal/mysite/test/_api/lists/GetByTitle('SharepointLearningPlan')/items",
headers:
{
'cache-control': 'no-cache',
Authorization: token.tokenType + ' ' + token.accessToken,
Cookie: 'odbn=1; WSS_FullScreenMode=false; rtFa=Fo9oO7...A==; FedAuth=77u...',
'accept-language': 'en-US,en;q=0.8',
'accept-encoding': 'gzip, deflate, sdch, br',
referer: '<botsite>/api/messages',
dnt: '1',
'content-type': 'application/json;odata=verbose',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36',
'x-requestdigest': '0x095398543A736B2AA0E6E5A8102640AF2944EB8352B192F6FFB3948047013C0E0B60767014D4775C358FED7B14075BDBAADC5A96F59875D8FC56E455BF1FAE67,01 Sep 2016 21:19:32 -0000',
accept: 'application/json;odata=nometadata'
}
};
然后我请求从我的共享点站点获取列表并收到错误:
ID4183: The Security Token failed Audience restriction validation.
【问题讨论】:
标签: node.js botframework