Skip to content

Instantly share code, notes, and snippets.

@jgw96
Created November 30, 2018 21:01
Show Gist options
  • Save jgw96/f6da076157695b71d069589bf2789077 to your computer and use it in GitHub Desktop.
Save jgw96/f6da076157695b71d069589bf2789077 to your computer and use it in GitHub Desktop.
export async function getUser(token: string) {
const headers = new Headers();
const bearer = "Bearer " + token;
headers.append("Authorization", bearer);
const options = {
method: "GET",
headers: headers
};
const graphEndpoint = "https://graph.microsoft.com/beta/me";
const response = await fetch(graphEndpoint, options);
const data = await response.json();
return data;
}
export async function getProfilePhoto(token: string) {
const headers = new Headers();
const bearer = "Bearer " + token;
headers.append("Authorization", bearer);
const options = {
method: "GET",
headers: headers
};
const graphEndpoint = "https://graph.microsoft.com/beta/me/photos/24x24/$value";
const response = await fetch(graphEndpoint, options);
const data = await response.blob();
return data;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment