Gets the username for the current user using the SSO API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { | |
console.log(exception.message); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment