- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想做的是使用 Microsoft 在 this article 中描述的“Web API 代表流”场景创建一个网络钩子(Hook)。
所以我从 Microsoft github example 开始并确保我可以通过 Graph API 成功获取用户个人资料。
然后我修改了获取用户配置文件以创建 Web Hook 的代码,因此代码如下所示:
// 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) != null
? ClaimsPrincipal.Current.FindFirst(ClaimTypes.Upn).Value
: ClaimsPrincipal.Current.FindFirst(ClaimTypes.Email).Value;
var result = await authenticationContext.AcquireTokenAsync(resource,new ClientCredential(clientId,clientSecret),new UserAssertion(assertion,assertionType,userName));
var accessToken = result.AccessToken;
// After getting the access token on behalf of the desktop WPF app,
// subscribes to get notifications when the user receives an email.
// This is the part that I put in.
var subscription = new Subscription
{
Resource = "me/mailFolders('Inbox')/messages",
ChangeType = "created",
NotificationUrl = "https://mycompany.com/subscription/listen",
ClientState = Guid.NewGuid().ToString(),
ExpirationDateTime = DateTime.UtcNow + new TimeSpan(0, 0, 4230, 0)
};
const string subscriptionsEndpoint = "https://graph.microsoft.com/v1.0/subscriptions/";
var request = new HttpRequestMessage(HttpMethod.Post, subscriptionsEndpoint);
var contentString = JsonConvert.SerializeObject(subscription, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
request.Content = new StringContent(contentString, System.Text.Encoding.UTF8, "application/json");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var response = await new HttpClient().SendAsync(request);
if (response.IsSuccessStatusCode)
{
// Parse the JSON response.
var stringResult = await response.Content.ReadAsStringAsync();
subscription = JsonConvert.DeserializeObject<Subscription>(stringResult);
}
我从响应中得到的错误是:
{
"error":
{
"code": "InvalidAuthenticationToken",
"message": "Access token validation failure.",
"innerError":
{
"request-id": "f64537e7-6663-49e1-8256-6e054b5a3fc2",
"date": "2017-03-27T02:36:04"
}
}
}
Webhook 创建代码直接取自 ASP.NET webhook github sample project ,我也已经确定可以成功运行了。
相同的访问 token 代码适用于原始用户配置文件读取代码:
// Call the Graph API and retrieve the user's profile.
const string requestUrl = "https://graph.windows.net/mycompany.com/me?api-version=2013-11-08";
request = new HttpRequestMessage(HttpMethod.Get, requestUrl);
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
var response = await new HttpClient().SendAsync(request);
所以我想知道:
最佳答案
"message": "Access token validation failure.",
该错误意味着您获得的资源访问 token 不正确。根据您的代码,您获得资源的访问 token :https://graph.windows.net ( Azure AD Graph API) ,但随后您使用该访问 token 访问 Microsoft Graph API( https://graph.microsoft.com ),因此访问 token 验证失败。
关于azure - 使用 "Web API on-behalf-of flow"创建 Microsoft Graph Webhook 时访问 token 验证失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43037574/
我正在尝试实现 kotlin stateflow,但不知道它不起作用的原因。 当前输出: 验证34567 预期输出: 验证 34567 验证失败 package stateflowDuplicate
最近我发现了一个我无法理解的流行为。 问题描述 考虑这种情况:你有一个父 flow 并且在它的 collect 中,你将有一个“子”flow 并调用 .collect(),像这样: parentFlo
我想通过 UML2 事件图为以下事件建模: 执行操作 1。此操作产生两个输出参数: Object1和对象 2。 执行操作 2。此操作需要 Object2 作为输入参数。它不需要 Object1 作为输
在 Vaadin 8 中,您可以在 Tab(属于 TabSheet)上设置一个图标: tab#setIcon(...) 在 Vaadin Flow(目前使用 14.1)中,我不知道如何在 Tab(属于
有什么办法可以做到这一点吗?如果存储库仅在 .git/config 中包含 git-flow 指令(如 ),则该存储库是否被视为已初始化 .... [gitflow "branch"] mas
the 2nd collecting below does not collect until I remove the first one. also read from [Manuel Vi
在官方示例中,他们总是有 /* @flow */在页面顶部。现在这对现有项目来说很好,很有帮助,我想选择加入每个文件的流程。从头开始构建一个新项目我只想在任何地方进行流类型检查,而不必输入 /* @f
Vaadin 突然停止构建我的库并出现以下错误。我已经跳了 Vaadin 舞(还有很多其他的东西),但我现在没主意了。我尝试为生产构建库(但对于开发也失败了)。 我正在使用 Vaadin Flow。
我注意到很多人和例子都使用 Flows 作为 List<> 的包装器,例如像这样: @Query("SELECT * from some_model ORDER BY some_field") fun
Vaadin 突然停止构建我的库并出现以下错误。我已经跳了 Vaadin 舞(还有很多其他的东西),但我现在没主意了。我尝试为生产构建库(但对于开发也失败了)。 我正在使用 Vaadin Flow。
关闭。这个问题是opinion-based 。目前不接受答案。 想要改进这个问题吗?更新问题,以便 editing this post 可以用事实和引文来回答它。 . 已关闭 3 年前。 Improv
git flow init后,如何删除git flow模型? 如何从 .git/config 文件中删除所有相关配置? $ git flow init # force reset $ git flow
我运行了 git init 并在选择第一个分支时犯了一个错误。现在我想重新运行它来更改设置,但它再也不会问第一个问题。 Which branch should be used for bringing
我刚刚开始一份新工作,他们的代码管理一团乱。通常情况下这没什么问题,我可以应付,但在这个地方,情况就糟糕得离谱了。 他们使用 TFS...对此我无能为力。没有机会介绍 git,但我一直在阅读有关 gi
我的应用程序有更新问题。我不太明白 subview 之间的数据流是怎么回事。 这是我目前的结构 ViewModel:ObsebsrvableObject MainView 与 ObservedObje
为什么“flow check-contents”需要使用 < 将文件重定向到其中,而“flow suggest”则不需要?看起来 check-contents 应该假设命令行参数是要检查的文件路径。
最近我在 Git 中发现了工作流的三个概念: GitFlow GitHub 流程 GitLab 流程 我读过 the nice articles关于它,但我不太了解 GitLab Flow。 简单地说
我们刚刚改用 Hg Flow,但我们还没有弄清楚的一件事是如何最好地使用 Jenkins。理想情况下,我们将有一个构建和测试开发的作业,一个构建和测试默认作业和其他作业,这些作业在创建功能或发布分支时
将 Vaadin 12 与 FormLayout 一起使用和标签左侧的输入字段。 我想设置标签列的宽度。如何使用 Java API 实现这一点? 最佳答案 用于设置个人 FormItem标签宽度和/或
我正在使用 React-Flow 来可视化 React 中组件的树状层次结构。每当您在 React-Flow 中创建自定义节点时,您都可以像这样在树中使用它: ,我就可以做到这一点。 .有没有
我是一名优秀的程序员,十分优秀!