首页 文章

Microsoft Graph Webhook缺少ClientState

提问于
浏览
4

我无法启动Microsoft Graph webhook订阅(特别是对于邮箱) . 在启动订阅时,似乎Microsoft接受我发送的所有参数以配置订阅但未通过总订阅,因为它从我已配置的 endpoints 接收到非2xx响应 .

我的 endpoints 将 401 发送回Microsoft的原因是因为包含订阅验证令牌的POST缺少clientState .

我使用clientState键值对来验证Microsoft和我的 endpoints 之间的所有通信 . 如果我的 endpoints 没有看到正确的clientState,它将返回 401 .

关于我可能缺少什么的想法,或者我是否应该以不同的方式解决这个问题?在我看来,允许我的 endpoints 接受未经身份验证的GET / POST不是一种选择 .

示例请求正文使用POST方法,包括 Headers 中的API密钥:

{
    "changeType": "created",
    "clientState": "testClientState",
    "resource": "users/<UserName>/messages",
    "expirationDateTime": "2017-08-10T10:24:57.0000000Z",
    "notificationUrl": "<EndpointURL>"
}

从Microsoft返回错误:

"error": {
    "code": "InvalidRequest",
    "message": "Subscription validation request failed. Must respond with 200 OK to this request.",
    "innerError": {
        "request-id": "adf7fc7b-6b14-4422-8526-c1391be8dd27",
        "date": "2017-08-07T16:24:59"
    }
}

我理解一切按预期工作,直到我的 endpoints 被发送验证令牌,因为我收到验证令牌,但我的 endpoints 拒绝它,因为它缺少客户端状态 .

endpoints 日志片段:

queryStringParameters": {
    "validationToken": "<ValidationToken sent by Microsoft>"
}

我的API endpoints 逻辑基于Microsoft的一些开发人员指南 . 特别是对于订阅创建我是using this guide .

看来这个问题是also asked but not answered on GitHub .

1 回答

  • 1

    我代表Microsoft Graph Web钩子团队......

    我们在MS Graph服务日志中验证了您的请求,并确认它在订阅验证阶段失败,因为您的终端的HTTP状态代码='未授权'...根据您的观察,一切都是正确的...

    By design, MS Graph Web hooks do not send the clientState header as part of the Subscription validation request. 在订阅验证期间,请不要期望此标头 .

    更多信息

相关问题