Office 365 'Create Event' Rest API 出现错误

Office 365 'Create Event' Rest API is giving error

我是 Whosebug 以及使用 node.js.

进行 office 365 开发的新用户

我正在使用本教程成功获取用户(我自己的 office 365 帐户)邮件和日历事件 (https://dev.outlook.com/RestGettingStarted/Tutorial/node)

但是当我试图在我的日历中创建一个事件时它给我以下错误 “{"error":{"code":"ErrorAccessDenied","message":"Access is denied. Check credentials and try again."}}”

请给我一些建议。

下面是我从[https://msdn.microsoft.com/office/office365/APi/calendar-rest-operations#CreateEvents]这里

复制的用于创建事件的代码
    function createEvent(response, request) {
var cookieName = 'node-tutorial-token';
   var cookie = request.headers.cookie;
//    if (cookie && cookie.indexOf(cookieName) !== -1) {
        console.log("Cookie: ", cookie);
        // Found our token, extract it from the cookie value
        var start = cookie.indexOf(cookieName) + cookieName.length + 1;
        var end = cookie.indexOf(';', start);
        end = end === -1 ? cookie.length : end;
        var token = cookie.substring(start, end);
        console.log("Token found in cookie: " + token);

var event = new outlook.Microsoft.OutlookServices.Event();
event.subject = 'Your Subject';
event.start = new Date("October 30, 2014 11:13:00").toISOString();
event.end = new Date("October 30, 2014 12:13:00").toISOString();

// Body
event.body = new outlook.Microsoft.OutlookServices.ItemBody();
event.body.content = 'Body Content';
event.body.contentType = outlook.Microsoft.OutlookServices.BodyType.Text;

// Location
event.location = new outlook.Microsoft.OutlookServices.Location();
event.location.displayName = 'Location';

// Attendee
var attendee1 = new outlook.Microsoft.OutlookServices.Attendee();
var emailAddress1 = new outlook.Microsoft.OutlookServices.EmailAddress();
emailAddress1.name = "abc";
emailAddress1.address = "abc@abcdt.onmicrosoft.com";

attendee1.emailAddress = emailAddress1;

event.attendees.push(attendee1);
 var outlookClient = new outlook.Microsoft.OutlookServices.Client('https://outlook.office365.com/api/v1.0', 
       authHelper.getAccessTokenFn(token));

outlookClient.me.calendar.events.addEvent(event)
    .then(function (response) {
    console.log(response._Id);
}, function (error) {
        console.log(error);

});

}

确保您的应用已请求 calendar.readwrite 权限,并且您需要此权限才能创建新活动。在您遵循的示例中,您的应用仅注册了 Calendar.Read 权限(见下文)。

您应该转至 https://dev.outlook.com/AppRegistration 以 Calendar.Read写入权限注册一个应用程序,这是创建新事件所必需的。