0

I need to create a calendar event in outlook using NodeJS script. I have searched every where and tried different npm packages but i didn't got the solution.

I have tried Node-Outlook NPM package but the documentation is not clear like how to create calendar event.

var outlook = require('node-outlook');

var newEvent = {
    "Subject": "Discuss the Calendar REST API",
    "Body": {
        "ContentType": "HTML",
        "Content": "I think it will meet our requirements!"
    }
};

let createEventParameters = {
    token: ['Access token'],
    event: newEvent,
    user : <user>
};
outlook.calendar.createEvents(createEventParameters, function (error, event) {
    if(error) {
        console.log(error);                 
    } else {
        console.log(event);                         
    }
});

This npm package return error :

REST request returned 401; body: {"error":{"code":"InvalidAudience","message":"The audience claim value is invalid 'aud'.

Please help me to solve this problem and also if you know any different way to create calendar event please suggest.

Thanks

shiva
  • 429
  • 1
  • 6
  • 18
  • Seems like your access token doesn't have proper claims as expected, drop that token on `jwt.io` and look for the `aud` field. – sujeet Oct 20 '20 at 03:40
  • It Gives me "aud": "00000003-0000-0000-c000-000000000000". What does it mean? – shiva Oct 20 '20 at 03:44

1 Answers1

0

try to set this permission Calendars.ReadWrite in API permissions in Azure configuration