我已经使用 Microsoft Graph API 创建了 webhook 项目来监控 Office 365 收件箱。
下面是我如何促进 HTTP 请求更新订阅的代码片段
AuthenticationResult authResult = await AuthHelper.GetAccessTokenAsync();
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", authResult.AccessToken);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
// Build the request.
string subscriptionsEndpoint = "https://graph.microsoft.com/v1.0/subscriptions/"+id;
var method = new HttpMethod("PATCH");
HttpRequestMessage request = new HttpRequestMessage(method, subscriptionsEndpoint);
//get the current time
var subscription = new Subscription
{
//Id = id,
ExpirationDateTime = DateTime.UtcNow + new TimeSpan(0, 0, 4230, 0)
};
有没有一种方法可以在用户不按“更新”按钮的情况下自动更新?
因为授权标头需要 AuthResult.accessToken 这将要求用户登录到 Office365 帐户。
请指教