Asp.net core 学习笔记之 Microsoft Graph API

早年如果我们要读写用户得 outlook 内容是比较麻烦的, 要用许多 smtp 之类的方式.

现在终于是有了 http 级的 API 可以 call 了.

不仅仅是 outlook, calendar 等等都可以直接用 graph api 读写哦. 

照着 step 做就可以了.

https://docs.microsoft.com/en-us/graph/tutorials/aspnet-core

其实我们直接用 identity 的 external login 也是可以拿到这个权限的. 加一点 scope 下去就可以了. 当然需要把 access token 和 refresh token 收好咯

services.AddAuthentication().AddMicrosoftAccount(options =>
{
    options.ClientId = "client id";
    options.ClientSecret = "client secret";
    options.SaveTokens = true;
    options.Scope.Add("https://graph.microsoft.com/User.ReadBasic.All");
    options.Scope.Add("https://graph.microsoft.com/Calendars.ReadWrite");
});

permission list 在这里

https://docs.microsoft.com/en-us/graph/permissions-reference#calendars-permissions

 

posted @ 2021-07-01 07:40  兴杰  阅读(234)  评论(0编辑  收藏  举报