从Office 365获取资源计划?

2024-10-03 06:26:27 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个python脚本,可以通过调用从公司的office365日历获取资源(房间)的时间表 https://outlook.office365.com/api/v1.0/users/<roomName@companyName.com>/calendarview?startDateTime=2016-08-07 22:00:00&endDateTime=2016-08-08 22:00:00

这好像不管用了? 据我所知,通过限制对资源日历的权限,API似乎发生了变化。 这是正确的假设还是我做错了什么?在

有没有一种方法可以实际获得资源的时间表?在

我最好用Python或C\


Tags: https脚本comapi公司资源时间表users
1条回答
网友
1楼 · 发布于 2024-10-03 06:26:27

你得到的错误信息是什么?如果您遇到类似The access token is acquired using an authentication method that is too weak to allow access for this application的错误,我们需要使用证书make来请求令牌,而不是使用客户机id和secret。在

以下是使用证书请求令牌以供参考的代码示例:

 public static async Task<string> GetTokenByCert(string clientId, string tenant, string certThumbprint,string resource)
    {
        string authority = $"https://login.windows.net/{tenant}";

        X509Certificate2 cert = CertHelper.FindCert(certThumbprint);
        var certCred = new ClientAssertionCertificate(clientId, cert);
        var authContext = new Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext(authority);
        AuthenticationResult result = null;
        try
        {
            result = await authContext.AcquireTokenAsync(resource, certCred);
        }
        catch (Exception ex)
        {
        }

        return result.AccessToken;
    }

有关配置/使用证书请求令牌的详细信息,请参阅here。在

相关问题 更多 >