简体   繁体   English

访问日历事件时使用Microsoft Graph API 401

[英]Microsoft Graph API 401 when accessing calendar events

I'm currently trying to create a basic website to run locally on a raspberry pi that shows me my outlook calendar for the day. 我目前正在尝试创建一个基本的网站,以便在树莓派上本地运行,从而向我显示当天的前景日历。 However, when I try and access the https://graph.microsoft.com/v1.0/me/events endpoint, I get a 401 unauthorized error. 但是,当我尝试访问https://graph.microsoft.com/v1.0/me/events端点时,出现401未经授权的错误。

This is for a simple node.js express server, with all of the code for interacting with the graph api coming from the javascript quickstart app provided by Microsoft. 这是用于简单的node.js Express服务器,用于与图形api交互的所有代码均来自Microsoft提供的javascript quickstart应用 The quickstart app works fine, and I'm able to see the json response for the https://graph.microsoft.com/v1.0/me endpoint that is part of the demo, but changing the endpoint causes a 401. 快速入门应用程序运行正常,并且我能够看到作为演示一部分的https://graph.microsoft.com/v1.0/me端点的json响应,但是更改该端点会导致401。

I've made sure in the azure app registration page that I've enabled the Calendar.read permission, and in my app I've added the calendar.read permission to my scope. 我已经确定在azure应用程序注册页面中已启用Calendar.read权限,并且在我的应用程序中已将calendar.read权限添加到了我的范围。 When I login, the login popup window asks for permission to read my calendar which to me says that the app should have access to my calendar. 登录时,登录弹出窗口会要求您阅读我的日历的权限,对我来说,该应用程序应该可以访问我的日历。

My application configuration (again based off of the quickstart app) looks like this: 我的应用程序配置(同样基于quickstart应用程序)如下所示:

const applicationConfig = {
    clientID: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
    authority: 'https://login.microsoftonline.com/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
    graphScopes: ['calendars.read', 'tasks.read'],
    graphEndpoint: 'https://graph.microsoft.com/v1.0/me/events',
};

Other than these changes, the rest of the code is identical to the sample code. 除了这些更改之外,其余代码与示例代码相同。

You should also include User.Read in your scopes. 您还应该在范围内包括User.Read From the documentation on User.Read : User.Read文档中

Allows users to sign-in to the app, and allows the app to read the profile of signed-in users. 允许用户登录到该应用,并允许该应用读取已登录用户的个人资料。 It also allows the app to read basic company information of signed-in users. 它还允许该应用读取已登录用户的基本公司信息。

const applicationConfig = {
    clientID: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
    authority: 'https://login.microsoftonline.com/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
    graphScopes: ['Users.Read', 'Calendars.Read', 'Tasks.Read'],
    graphEndpoint: 'https://graph.microsoft.com/v1.0/me/events',
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 Microsoft 图形添加多个日历事件 - How to add multiple calendar events using Microsoft graph 使用 API GRAPH 创建 onlineMeeting - GET https://graph.microsoft.com/beta/me/onlineMeetings 401(未经授权) - Create onlineMeeting with API GRAPH - GET https://graph.microsoft.com/beta/me/onlineMeetings 401 (Unauthorized) Microsoft Graph API-v1.0 / me / events禁止使用403 - Microsoft Graph API - 403 Forbidden for v1.0/me/events 从 Microsoft Graph Api 访问组时出现问题 - Issue while accessing Groups from Microsoft Graph Api 通过node.js访问MusicKit API时出现401错误 - 401 error when accessing MusicKit API via node.js 如何使用 Microsoft-Graph 和 NodeJS 按日历名称获取日历的事件? - How to get calender's events by calendar name, with Microsoft-Graph and NodeJS? Google Calendar API 在列出活动时不返回与会者 - Google Calendar API not returning attendees when listing events 使用Google Calendar API返回401(未经授权) - Using Google Calendar API returns 401 (unauthorized) Vue.Js 中 Microsoft Graph API 日历列表视图数据的前端可以使用什么样的分页 - What kind of pagination can be used in frontend for Microsoft Graph API Calendar List view data in Vue.Js 使用Calendar API创建的事件未显示在日历中 - Events created with Calendar API not showing up in the calendar
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM