小编Leo*_*hou的帖子

使用"代表流的Web API"创建Microsoft Graph webhook时访问令牌验证失败

我想要做的是使用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

1
推荐指数
1
解决办法
3971
查看次数