Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

203
Views
How to display the binary account image received from msal graph API?

I am able to query the msal graph api by using https://graph.microsoft.com/v1.0/me/photo/$value but once I have the response, which based on [the documentation][1] is a binary value, I am unable to actually display this in my Vue app. I have tried using createObjectURL to make a blob and setting that as the src attribute of the img element like this:

const url = window.URL || window.webkitURL;
const blobUrl = url.createObjectURL(response.data);
document.getElementById("imageElement").setAttribute("src", blobUrl);

but I get the error:

TypeError: Failed to execute 'createObjectURL' on 'URL': Overload resolution failed.

I am getting the image like this:

axios.get("https://graph.microsoft.com/v1.0/me/photos/48x48/$value", {
   headers: {
   Authorization: "Bearer " + "xxxxxxx" // this is the auth token
    }
})

.then(response => {
    const url = window.URL || window.webkitURL;
    const blobUrl = url.createObjectURL(response.data);
    document.getElementById("imageElement").setAttribute("src", blobUrl);
});
```


  [1]: https://docs.microsoft.com/en-us/graph/api/profilephoto-get?view=graph-rest-1.0
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Give this a try.

yourImg.src = 'data:image/jpeg;base64, ' + Buffer.from(response.data, 'binary').toString('base64');

Also check the answers and comments here

about 4 years ago · Juan Pablo Isaza Report

0

You need to call blob() on the response: See this example

fetch("https://random.imagecdn.app/500/500").then(async response => {
  const url = window.URL || window.webkitURL;
  const blobUrl = url.createObjectURL(await response.blob());
  document.getElementById("imageElement").setAttribute("src", blobUrl);
});
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!