Forum Discussion

Deleted's avatar
Deleted
Apr 15, 2020
Solved

[Microsoft Teams] Cannot access images from clipboard

Hi people,
I am working on a bot who receives messages from Teams and sends them to another application.

So far everything works fine, I can move texts, emojis, files etc.
But I have a problem with images in the clipboard.

When sending a normal file, it is saved to SharePoint and I can access it with the Attachment.Content["downloadUrl"] of the activity.

But when I insert images from the clipboard, it is stored in another way, I get two attachments with different urls (one for layout and one for the image resource, I suppose?), but when trying to GET the image, I receive an 401 Unauthorized for both urls.

 Is there a way to access these images pasted from the clipboard, or are these only visible/accessible from inside Microsoft Teams?

Help me, Obi-Wan Kenobi. You're my only hope.

Thank you for your time!

  •  

    Answered in https://github.com/MicrosoftDocs/msteams-docs/issues/1561

    One can use the MicrosoftAppCredentials to receive a JWT Token to access the images.

    var token = await new MicrosoftAppCredentials("appId", "password").GetTokenAsync();httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
  •  

    Answered in https://github.com/MicrosoftDocs/msteams-docs/issues/1561

    One can use the MicrosoftAppCredentials to receive a JWT Token to access the images.

    var token = await new MicrosoftAppCredentials("appId", "password").GetTokenAsync();httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);

Resources