如何使用Microsoft的Graphi API在Outlook日历中创建事件

时间:2019-04-22 09:19:37

标签: node.js microsoft-graph microsoft-graph-calendar

我有一个Node.js应用,需要在Outlook中创建日历event。我遵循the Node tutorial,并创建了一个基本应用程序,可以在其中连接到我的帐户。登录后会给我以下响应:

{ 
    token_type: 'Bearer',
    scope: 'openid profile User.Read Mail.Read Calendars.ReadWrite',
    expires_in: 3600,
    ext_expires_in: 3600,
    access_token: 'dsfsdfsfd',
    refresh_token: 'fdgdfgd',
    id_token: 'fdgdfg',
    expires_at: 2019-04-22T09:54:53.951Z 
}

然后我去邮递员发出以下请求:

POST https://graph.microsoft.com/v1.0/me/calendar/events

Authorization: Bearer access_token
Content-type: application/json

{
  "subject": "Let's go for lunch",
  "body": {
    "contentType": "HTML",
    "content": "Does mid month work for you?"
  },
  "start": {
      "dateTime": "2019-03-15T12:00:00",
      "timeZone": "Pacific Standard Time"
  },
  "end": {
      "dateTime": "2019-03-15T14:00:00",
      "timeZone": "Pacific Standard Time"
  },
  "location":{
      "displayName":"Harry's Bar"
  },
  "attendees": [
    {
      "emailAddress": {
        "address":"user@email.com",
        "name": "Adele Vance"
      },
      "type": "required"
    }
  ]
}

我基本上复制了Create Event example

但是,这返回

{
  "error": {
    "code": "InvalidAuthenticationToken",
    "message": "Access token validation failure.",
    "innerError": {
      "request-id": "request--id.....",
      "date": "2019-04-22T09:01:20"
    }
  }
}

首先,我对要发布的网址感到困惑:

我尝试了两个版本,甚至用v2.0替换了v1.0,但是它总是给我同样的InvalidAuthenticationToken错误:

我去https://jwt.ms并粘贴了我的id_token,这似乎是正确的。

知道我在做什么错吗?

PS:我正在尝试连接到我的Hotmail帐户上的个人Outlook日历。我正在从事的项目是针对一个客户的,他们的公司名称(user@mycompany.com上有一个Office 365,但在制定工作流程之前,我不希望使用他们的帐户。

0 个答案:

没有答案