0
  • In Microsoft Teams, I have crated an App that lists files of a certain type in a Tab
  • The use case is that the contents of the file need to be read by my Javascript
  • the Javascript in the Tab already successfully gets an ID Token and Access Token (via ADAL)
  • this code already successfully lists the DriveItems in the group the current logged in user can see via https://graph.microsoft.com/v1.0/groups/${groupId}/drive/root/search(q='{pdf}');`
  • when I attempt to GET the DriveItem via https://graph.microsoft.com/v1.0/groups/${groupId}/drive/items/${itemId}/content

    • where the itemId is returned from the first call

    • I successfully see the HTTP 302 from the https://graph.microsoft.com endpoint redirecting to https://<thesharepointsite>.sharepoint.com/<etc>

  • Axios (and the Microsoft Graph Javascript API) are successfully traversing to the redirect

  • Postman, with the same https://graph... URL with the AccessToken successfully downloads the binary content from the 302 redirect (so it is not an Auth issue)

PROBLEM

  • in Microsoft Teams, inside my Tab, the browser (built inside of the Teams desktop app) HTTP calls to https://<thesharepointside>.sharepoint.com respond with a 405 error on the OPTIONS call
  • usually this means there is a CORS issue, and so the solution is to add the domain to the validDomains of the app

Attempted Solution

  • the Manifest has the following entries in validDomains
"validDomains": [
       ...

        "*.sharepoint.com",
        "graph.microsoft.com",
        "login.microsoftonline.com"
    ]

In all instances, I get 405 on the OPTIONS call

No file download from within the Tab within Microsoft Teams.

Suggestions?

NickHodge
  • 313
  • 3
  • 10

1 Answers1

1

THIS MAY answer your question in the future

  • my code now does a https://graph.microsoft.com/v1.0/groups/${groupId}/drive/items/${itemId}
  • this is an Instance of DriveItem and returns a property on the JSON response: @microsoft.graph.downloadUrl

  • as per Microsoft Graph API Download File content return Unauthorized 401 this is a short-lived URL you can traverse without Auth headers

  • the content of my file was returned successfully (no CORS issue)

  • I can now download the contents of the DriveItem within a Tab

  • I hope this helps someone

NickHodge
  • 313
  • 3
  • 10