我想要做的是使用Microsoft 本文中描述的"Web API代表流"方案来创建Web挂钩.
所以我从Microsoft github示例开始,确保我可以通过Graph API成功获取用户配置文件.
然后我修改了获取用户配置文件的代码来创建Web挂钩,因此代码如下所示:
// Authentication and get the access token on behalf of a WPF desktop app.
// This part is unmodified from the sample project except for readability.
const string authority = "https://login.microsoftonline.com/mycompany.com";
const string resource = "https://graph.windows.net";
const string clientId = "my_client_id";
const string clientSecret = "my_client_secret";
const string assertionType = "urn:ietf:params:oauth:grant-type:jwt-bearer";
var user = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value;
var authenticationContext = new AuthenticationContext(authority,new DbTokenCache(user));
var assertion = ((BootstrapContext) ClaimsPrincipal.Current.Identities.First().BootstrapContext).Token;
var userName = ClaimsPrincipal.Current.FindFirst(ClaimTypes.Upn) …Run Code Online (Sandbox Code Playgroud) azure webhooks azure-active-directory azure-ad-graph-api microsoft-graph