我正在尝试使用Office 365 API在JavaScript中创建一个webapp。我浏览了https://msdn.microsoft.com/en-us/office/office365/api/mail-rest-operations链接,找到了以下代码段:
var authContext;
var authToken; // for use with creating an outlookClient later.
authContext = new O365Auth.Context();
authContext.getIdToken("https://outlook.office365.com/")
.then((function (token) {
authToken = token;
// The auth token also carries additional information. For example:
userName = token.givenName + " " + token.familyName;
}).bind(this), function (reason) {
console.log('Failed to login. Error = ' + reason.message);
});
// Once the authToken has been acquired, create an outlookClient. One place to do this is inside of the
// ".then" function callback of authContext.getIdToken(...) above.
var outlookClient = new Microsoft.OutlookServices.Client('https://outlook.office365.com/api/v1.0', authToken.getAccessTokenFn('https://outlook.office365.com'));
当我使用上面的代码时,它会抛出一个' O365Auth'没有定义的。如何创建Outlook客户端对象?我是否遗漏了任何需要作为项目一部分包含的JavaScript库?我是否需要从nuget管理器获取库?
我在napa中创建了项目,后来又将其导入VS2013。
如果需要更多详细信息,请与我们联系。
谢谢!
答案 0 :(得分:0)
根据此Github repository from the Office Dev team:
答案 1 :(得分:0)
那将是Active Directory Authentication Library (ADAL) for JavaScript。这里有关于在OfficeDev GitHub上创建简单邮件应用程序的教程:https://github.com/OfficeDev/O365-JavaScript-GetStarted。