简体   繁体   English

调用Outlook API以使用Ajax调用将事件添加到Outlook日历

[英]Calling Outlook API to Add event to outlook calendar using ajax call

I need to Add an event from my database to outlook calendar for which I have been trying to make an ajax call to the outlook auth API first which looks like this 我需要将数据库中的事件添加到Outlook日历中,而我一直试图先对其进行Outlook身份验证API的Ajax调用,如下所示

$scope.authorizeOutlook = function () {

    let redirect = 'http://localhost:51419';
    let clientId = 'xxx';

    var authData = 'client_id=' + clientId + '&response_type=code&redirect_uri=' + redirect + '&response_mode=query&scope=https%3A%2F%2Fgraph.microsoft.com%2Fcalendars.readwrite%20&state=12345';
    debugger
    $.ajax({
        url: 'https://login.microsoftonline.com/common/oauth2/v2.0/authorize',
        type: 'POST',
        host: 'https://login.microsoftonline.com',
        contentType: "application/x-www-form-urlencoded",
        contentLength: "600",
        data: authData,
        success: function (response) {
            debugger;
            alert(response.status);
            //alert("success");
        },
        error: function (response) {
            alert(response.status);
            //alert("fail");
        }
    });
}

But I am getting response status as 0. What does that mean? 但是我的响应状态为0。这是什么意思? Where am I doing it wrong? 我在哪里做错了?

If you use Oauth2.0, you need to add " token-type: Bearer ". 如果使用Oauth2.0,则需要添加“令牌类型:承载”。

Reference from: 参考来自:

Get access tokens to call Microsoft Graph 获取访问令牌以调用Microsoft Graph

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM