我目前正在为Outlook开发角度插件,并且该插件的部分功能要求我的远程服务从Outlook中获取电子邮件的附件。
我一直在关注this Docs link here in regards to my functionality.
因此,目前,我可以通过Office.js以我的角度代码获取附件令牌,并将其与ExchangeWebServiceURL一起传递给我的远程服务:
Office.context.mailbox.getCallbackTokenAsync((result) => {
if (result.status === Office.AsyncResultStatus.Succeeded) {
this.outlookServiceRequest.attachmentToken = result.value;
}
});
但是一旦我到达这里
ExchangeService exchangeService = new ExchangeService();
exchangeService.Url = new Uri(attachmentsRequest.exchangeWebServiceUrl);
exchangeService.Credentials = new OAuthCredentials(attachmentsRequest.attachmentToken);
var attachmentIds = new List<string>();
foreach (OutlookAttachmentDetails attachment in attachmentsRequest.AttachmentArray)
{
attachmentIds.Add(attachment.id);
}
var attachmentResponses = exchangeService.GetAttachments(attachmentIds.ToArray(), null, new PropertySet(BasePropertySet.FirstClassProperties, ItemSchema.MimeContent));
由于来自ExchangeWebServiceUrl的401未经授权错误,该过程将在GetAttachments调用上失败。
我环顾四周,但是没有人遇到这个问题。我已在清单中为我的“加载到ReadWriteMailbox的加载项”设置了权限,但是问题仍然存在。
我已经尝试通过使用Web浏览器版本的Outlook在Office桌面客户端和Chrome上运行它来尝试此操作,但是遇到相同的问题。
以前有人遇到过吗?
编辑:我应该注意,如果我将凭据设置为
,则可以访问Exchange Web服务。exchangeService.Credentials = new WebCredentials("myUsername", "MyPassword");
因此似乎带有回调令牌。
已解码的令牌返回以下内容:
{“ nameid”:“ 641fdcd4-10dd-4441-ac93-41f519e4ad41@venom.local”,
“ ver”:“ Exchange.Callback.V1”,“ appctxsender”: “ https://localhost:44364/AddinClient@venom.local”,“ appctx”: “{\” SMTP \ “:\” MyEmail \ “\ ”范围\“:\ ”ParentItemId:AAMkAGY3N2QyYzI2LWRhZTUtNGU3My05MzFmLTYwZGZhZmYyN2QzOQBGAAAAAAAdJ5 + qR8pATpmqkddPNb2NBwBgP9yTrGVtSIiRWRnnYVBWAAAAAAEMAABgP9yTrGVtSIiRWRnnYVBWAAA5fvGXAAA = \“}”, “ iss”:“ 00000002-0000-0ff1-ce00-000000000000@venom.local”,“ aud”: “ 00000002-0000-0ff1-ce00-000000000000/outlook.myemailonline.co.uk@venom.local”,“ exp”:1546249394,“ nbf”:1546249094 }
我尝试调用GetAttachments方法时返回的错误是:
请求失败。远程服务器返回错误:(401) 未经授权
我从回调中获得的EWS令牌是:
“eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6InZDcjV1QmxZTmlXZk9udC1iQlFxVXhXYXBaRSJ9.eyJuYW1laWQiOiI2NDFmZGNkNC0xMGRkLTQ0NDEtYWM5My00MWY1MTllNGFkNDFAdmVub20ubG9jYWwiLCJ2ZXIiOiJFeGNoYW5nZS5DYWxsYmFjay5WMSIsImFwcGN0eHNlbmRlciI6Imh0dHBzOi8vbG9jYWxob3N0OjQ0MzY0L0FkZGluQ2xpZW50QHZlbm9tLmxvY2FsIiwiYXBwY3R4Ijoie1wic210cFwiOlwiYWZlcmd1c29uQGZpcmVmaXNoc29mdHdhcmUuY29tXCIsXCJzY29wZVwiOlwiUGFyZW50SXRlbUlkOkFBTWtBR1kzTjJReVl6STJMV1JoWlRVdE5HVTNNeTA1TXpGbUxUWXdaR1poWm1ZeU4yUXpPUUJHQUFBQUFBQWRKNStxUjhwQVRwbXFrZGRQTmIyTkJ3QmdQOXlUckdWdFNJaVJXUm5uWVZCV0FBQUFBQUVNQUFCZ1A5eVRyR1Z0U0lpUldSbm5ZVkJXQUFBNWZ2R1hBQUE9XCJ9IiwiaXNzIjoiMDAwMDAwMDItMDAwMC0wZmYxLWNlMDAtMDAwMDAwMDAwMDAwQHZlbm9tLmxvY2FsIiwiYXVkIjoiMDAwMDAwMDItMDAwMC0wZmYxLWNlMDAtMDAwMDAwMDAwMDAwL291dGxvb2subXllbWFpbG9ubGluZS5jby51a0B2ZW5vbS5sb2NhbCIsImV4cCI6MTU0NjI0OTM5NCwibmJmIjoxNTQ2MjQ5MDk0fQ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