简体   繁体   English

尝试将应用发布到 Microsoft graph API 目录时出现“上下文为 null 或 TenantId 为 null 或 UserId 为空”

[英]"Context is null or TenantId is null or UserId is null" when attempting to publish an app to catalog with Microsoft graph API

I'm trying to programmatically publish our MS Teams app to a tenant's app catalog after an admin grants consent (via the admin consent flow documented here ).在管理员授予同意后(通过此处记录的管理员同意流程),我正在尝试以编程方式将我们的 MS Teams 应用程序发布到租户的应用程序目录。

To do this, I found the endpoint POST https://graph.microsoft.com/v1.0/appCatalogs/teamsApps in the Graph API docs , which according to the docs has the following signature:为此,我在 Graph API 文档中找到了端点POST https://graph.microsoft.com/v1.0/appCatalogs/teamsApps ,根据文档,它具有以下签名:

POST https://graph.microsoft.com/v1.0/appCatalogs/teamsApps
Content-type: application/zip
Content-length: 244

[Zip file containing a Teams app package]

However, when I POST to the above endpoint, I get the following error:但是,当我 POST 到上述端点时,出现以下错误:

{
  "error": {
    "code": "BadRequest",
    "message": "Context is null or TenantId is null or UserId is null",
    "innerError": {
      "date": "2020-07-28T20:33:11",
      "request-id": <some UUID>
    }
  }
}

For authentication, I am passing in the auth token I receive from "https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token" , where tenant_id is the same tenant I am trying to add the app to.为了进行身份验证,我传入了从"https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token"收到的身份验证令牌,其中 tenant_id 与我尝试添加应用程序的租户相同到。

I suspect that there might be either an issue with the consent being granted or the internal contents of our app's.zip but I can't tell which is the case.我怀疑可能存在授予同意的问题或我们应用程序 .zip 的内部内容的问题,但我无法判断是哪种情况。 I don't see any error conditions documented on the Graph API docs page, so any help would be greatly appreciated.我没有看到 Graph API 文档页面上记录的任何错误情况,因此非常感谢任何帮助。

The appCatalog publish endpoint requires an oauth user-specific delegated token, which is different from the token received from https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token . appCatalog 发布终结点需要一个 oauth 用户特定委托令牌,它不同于从https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token收到的令牌。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM