Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to Download Attachment Files from Microsoft Teams Messages (SharePoint URL Authentication Issue) #12244

Open
YavneshSM opened this issue Feb 5, 2025 · 3 comments
Assignees

Comments

@YavneshSM
Copy link

YavneshSM commented Feb 5, 2025

Type of issue

Other (describe below)

Feedback

I am working on a bot that retrieves messages posted in Microsoft Teams. Using the Microsoft Graph API, I can successfully get the message details, including the attachments associated with a message. The relevant API call structure is:

/users/{aad_user_id}/chats/{meeting_id}/messages/{message_id}

From the response, I can extract the attachment details such as:

Attachment ID
Attachment Name
Attachment Content URL (SharePoint URL)

Here is a sample content URL that I receive:
https://salientmind-my.sharepoint.com/personal/yavnesh_sharma_salientminds_com/Documents/Book1.xlsx

When trying to download the attachment from the SharePoint URL, the file is not accessible due to SharePoint's permission requirements. It prompts for a Microsoft account login to access the file.

Is there a way to retrieve the file programmatically without requiring user authentication?
Any API recommendations or Graph permissions required to download the file directly?

Page URL

https://learn.microsoft.com/en-us/microsoftteams/platform/bots/how-to/bots-filesv4

Content source URL

https://github.com/MicrosoftDocs/msteams-docs/blob/main/msteams-platform/bots/how-to/bots-filesv4.md

Author

@surbhigupta

Document Id

6bcc7af0-05b8-021d-0aad-8ac89e3d595c

@sayali-MSFT
Copy link
Collaborator

sayali-MSFT commented Feb 6, 2025

@YavneshSM ,Thank you for your message! To help us reproduce the issue on our end, could you please share the following?

  1. Reproduction Steps: What steps did you take leading up to the problem?
  2. Error Logs: If available, please share any relevant error logs or messages that you’ve received.
  3. Minimal Code Snippet: A minimal code snippet that demonstrates the issue you're encountering.

Providing this information will allow us to better understand the context and assist you more effectively.

Also refer the below document-
1.https://learn.microsoft.com/en-us/graph/api/resources/onedrive?view=graph-rest-1.0
2.https://learn.microsoft.com/en-us/graph/api/driveitem-get-content?view=graph-rest-1.0&tabs=http

@YavneshSM
Copy link
Author

@sayali-MSFT

  1. Reproduction Steps
    After adding the bot to the meeting and giving required consents.
    Upload any resource in a meeting chat.

  2. Error Logs
    {"error":{"code":"InvalidAuthenticationToken","message":"Signing key is invalid.","innerError":{"date":"2025-02-10T12:21:18","request-id":"0010937a-34d7-422f-a5e1-ab64fd25e922","client-request-id":"0010937a-34d7-422f-a5e1-ab64fd25e922"}}}

  3. Minimal code snippet

Image

@sayali-MSFT
Copy link
Collaborator

sayali-MSFT commented Feb 11, 2025

@YavneshSM , Thanks for sharing the information.
The error message InvalidAuthenticationToken with the message Signing key is invalid indicates that there is an issue with the authentication token being used by your bot. This error is typically related to the token being expired, improperly signed, or otherwise invalid.

Please ensure that the token is issued for the correct resource and audience, specifically for the Microsoft Graph API with the necessary scopes required by your bot. Additionally, verify that the token is obtained using the correct client ID, client secret, and other credentials.
If you are using the On-Behalf-Of (OBO) flow, kindly confirm that the OBO token is being correctly obtained and utilized. Similarly, if you are using the client credentials flow, please ensure that the client ID, client secret, and tenant ID are correctly configured.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants