从2019年3月18日起,Graph API返回403禁止

时间:2019-03-20 12:13:38

标签: c# microsoft-graph

以下实现在2019年3月18日之前可以正常运行。

var graphClient = this.graphService.GraphClient;
var reqUrl = graphClient
    .Me
    .Request()
    .RequestUrl;
reqUrl += "/findMeetingTimes";
var headers = new Dictionary<string, string>
    { { "Prefer", $"outlook.timezone = \"{parameter.PreferredTimeZone}\"" },
    };

var noOfMeetingSlots = parameter.MaxCandidates ?? 5;

parameter.MaxCandidates = 25;

var hrm = this.graphService.CreateHttpPostRequest<MeetingSuggestionParameter>(
    parameter,
    new Uri(reqUrl),
    headers);

await graphClient
    .AuthenticationProvider
    .AuthenticateRequestAsync(hrm)
    .ConfigureAwait(false);

MeetingSuggestionResult result = null;

try
{
    using(HttpResponseMessage response = await graphClient
            .HttpProvider
            .SendAsync(hrm)
            .ConfigureAwait(false)) {

例外:

graphClient.HttpProvider.SendAsync throws 403 Forbidden. 
Exception Message:
Code: UnknownError

Inner error

StackTrace 
at Microsoft.Graph.HttpProvider.SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)
   at Publicis.Marcel.Services.Calendar.CalendarService.FindMeetingSuggesstionsWithParametersAsync(MeetingSuggestionParameter parameter) in E: \Assistant2\o365\Services\Publicis.Marcel.Services.Calendar\Concrete\CalendarService.cs:line

以下代码段可以在Client SDK中使用:

var re = await graphClient
    .Me
    .FindMeetingTimes(
        Attendees,
        null,
        null,
        new Duration(parameter.MeetingDuration),
        parameter.MaxCandidates,
        parameter.IsOrganizerOptional,
        parameter.ReturnSuggestionReasons,
        parameter.MinimumAttendeePercentage)
    .Request()
    .PostAsync()
    .ConfigureAwait(false);

我已经检查过的东西

  1. Azure AD服务主要权限。它确实有caledar.readcalendar.read.Shared

这一直在生产中,直到2019年3月18日它开始抛出403 Forbidden

0 个答案:

没有答案