简体   繁体   中英

"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 ).

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:

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:

{
  "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.

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. I don't see any error conditions documented on the Graph API docs page, so any help would be greatly appreciated.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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