我正在尝试使用office.js为Outlook创建一个插件。一个星期以来,我一直在使用makeEwsRequestAsync收到accessRestricted错误。当我再次阅读该文档时,它说我必须在交换服务器中将oauthentication显式设置为true。当我检查如何将oauthentication设置为true时,在page的顶部,我看到该命令仅存在于本地交换服务器中。我购买了一个在线交换服务器,列出的命令在我的环境中不起作用。我一直在向Microsoft抱怨,他们应该把这些信息放在最前面,但是Microsoft的某人给我发消息,并说在联机使用交换时,oauthentication会自动设置为true。这似乎是错误的,因为我使用在线交换的管理员帐户收到相同的错误。我已经在下面发布了错误消息。错误消息似乎与配置不当有关,但我也在下面发布了我的代码。
function getCreateFolderXMLRequest(request) {
/*
example request parameter
<t:Folder>
<t:DisplayName>Folder1</t:DisplayName>
</t:Folder>
<t:Folder>
<t:DisplayName>Folder2</t:DisplayName>
</t:Folder>
*/
var completeRequest =
'<?xml version="1.0" encoding="utf-8"?>' +
'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/ "' +
' xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types">' +
" <soap:Body>" +
' <CreateFolder xmlns="https://schemas.microsoft.com/exchange/services/2006/messages">' +
" <ParentFolderId>" +
' <t:DistinguishedFolderId Id="msgfolderroot"/>' +
" </ParentFolderId>" +
" <Folders>" +
request +
" </Folders>" +
" </CreateFolder>" +
" </soap:Body>" +
"</soap:Envelope>";
return completeRequest;
}
export default function createFolders(listOfFolders, callback) {
const folderHeader = "<t:Folder> <t:DisplayName>";
const folderFooter = "</t:DisplayName> </t:Folder>";
var xmlFolders = [];
for (var folderName of listOfFolders) {
xmlFolders.push(folderHeader + folderName + folderFooter);
}
const folderXMLRequest = getCreateFolderXMLRequest(xmlFolders.join(" "));
Office.onReady(() => {
Office.context.mailbox.makeEwsRequestAsync(folderXMLRequest, callback);
});
}
我会说是的,因为文档提供了两种设置oauth的方式,并且两种方式都明确指出它必须是本地交换服务器。 https://docs.microsoft.com/en-us/office/dev/add-ins/outlook/web-services#authentication-and-permission-considerations-for-makeewsrequestasync