当我尝试更新用户日历中的事件时,我收到此错误。 根据MS,所需的范围是wl.calendars_update,它完全放在我的代码中。
知道为什么会这样吗?
request_token_unauthorized:Microsoft.Live.LiveConnectException:提供的访问令牌无权访问此资源。需要具有以下范围之一的访问令牌:'wl.contacts_calendars_update'。
这是抛出异常的代码(我把它抛出让我可以更好地看到错误)
public void UpdateEvent(LiveConnectSession session)
{
//session = MainPage.session;
var coco = StartDate[0].ToString("0000", null) + "-" + StartDate[1].ToString("00", null) + "-" + StartDate[2].ToString("00", null) + "T" + StartDate[3].ToString("00", null) + ":" + StartDate[4].ToString("00", null) + ":" + StartDate[5].ToString("00", null) + "+00:00";
var koko = Stuff.ReturnUnixTimeFromInt32Vector(EndDate);
// GenerateData();
AppointmentCustom c = new AppointmentCustom
{
Location = Where.Text,
Subject = Subject.Text,
Withwho = withwho.Text,
startday = when.Value.Value,
endday = Untill.Value.Value,
starthour = StartingWhen.Value.Value,
endhour = UntillWhen.Value.Value,
wasuploaded = false
};
var calEvent = new Dictionary<string, object>();
calEvent.Add("name", c.Subject);
calEvent.Add("description", c.Subject + " with " + c.Withwho + " at " + c.Location);
calEvent.Add("start_time", coco);
calEvent.Add("end_time", koko);
calEvent.Add("location", c.Location);
calEvent.Add("is_all_day_event", false);
calEvent.Add("availability", "busy");
calEvent.Add("visibility", "private");
LiveConnectClient updateEvent = new LiveConnectClient(session);
updateEvent.PutCompleted +=
new EventHandler<LiveOperationCompletedEventArgs>(updateEvent_PutCompleted);
updateEvent.PutAsync("event.8c8ce076ca27823f.9690899aeeae4e97be18cdc75b644454.3b4985a7bdd24958a5a9aac1e2ad970b", calEvent);
}
void updateEvent_PutCompleted(object sender, LiveOperationCompletedEventArgs e)
{
if (e.Error == null)
{
}
else
{
throw new InvalidOperationException(e.Error.ToString());
}
}
这是主屏幕上的用户控件弹出窗口。我只是从MainPage调用该方法,并将身份验证事件中的会话作为参数传递给此方法。