在向Outlook Calendar API(创建事件)提出请求时,如何添加权限?
我试图将Outlook Calendar API(创建事件)添加到我的Web应用程序中,但遇到了未授权的错误。所以我想这可能是我没有添加权限的原因吗?
这是我的ajax函数:
function addEvent(){
var newEvent = {};
newEvent.subject = document.getElementById('event-name').value;
newEvent.body = document.getElementById('event-des').value;
newEvent.start = document.getElementById('start-time').value;
newEvent.end = document.getElementById('end-time').value;
newEvent.location = document.getElementById('location').value;
console.log(JSON.stringify(newEvent));
const xhttp = new XMLHttpRequest();
xhttp.open("POST", "https://graph.microsoft.com/v1.0/me/events", true);
xhttp.setRequestHeader("Content-type","application/json");
res.setHeader('prefer', 'outlook.timezone="Pacific Standard Time"');
xhttp.send(JSON.stringify(newEvent));
}
但是我有一个未经授权的错误,可以向 https:htttps:htttps: //graph.microsoft.com/v1.0/me/events 。有人可以指出我在这里缺少什么吗?我非常陌生,任何帮助将不胜感激。
I was trying to add outlook calendar api (create event) to my web app but stuck on an error of unauthorization. So I guess it might be the reason that I did not add permission?
This is my ajax function:
function addEvent(){
var newEvent = {};
newEvent.subject = document.getElementById('event-name').value;
newEvent.body = document.getElementById('event-des').value;
newEvent.start = document.getElementById('start-time').value;
newEvent.end = document.getElementById('end-time').value;
newEvent.location = document.getElementById('location').value;
console.log(JSON.stringify(newEvent));
const xhttp = new XMLHttpRequest();
xhttp.open("POST", "https://graph.microsoft.com/v1.0/me/events", true);
xhttp.setRequestHeader("Content-type","application/json");
res.setHeader('prefer', 'outlook.timezone="Pacific Standard Time"');
xhttp.send(JSON.stringify(newEvent));
}
But I got an error of unauthorized to make post request to https://graph.microsoft.com/v1.0/me/events. Can any one point out what I am missing here? I am very new to this, any help would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
了解如何通过Microsoft Graph对权限进行身份验证并使用权限安全访问数据。探索以下文档以了解有关应用程序注册,身份验证库,授权和Microsoft Identity平台的其他部分,该平台支持Microsoft Graph开发中的Microsoft Graph开发。 /auth/“ rel =“ nofollow noreferrer”> Microsoft Graph Auth概述部分以获取更多信息。
Learn how to authenticate and work with permissions to securely access data through Microsoft Graph. Explore the documentation below to learn about app registration, authentication libraries, authorization, and other parts of the Microsoft identity platform that support Microsoft Graph development in the Microsoft Graph auth overview section for more information.