Skip to content

Instantly share code, notes, and snippets.

Created July 27, 2020 14:51
What would you like to do?
Gets the username for the current user using the SSO API
export async function getUserName() {
try {
let tokenData = await OfficeRuntime.auth.getAccessToken({ allowSignInPrompt: false, forMSGraphAccess: true });
var parts = tokenData.split(".");
var token = JSON.parse(atob(parts[1]));
return token.preferred_username;
catch (exception) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment