Skip to content

Instantly share code, notes, and snippets.

@cjvandyk
Created April 19, 2023 12:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cjvandyk/25367b7d0ffb738ca10b46ec5d91569d to your computer and use it in GitHub Desktop.
Save cjvandyk/25367b7d0ffb738ca10b46ec5d91569d to your computer and use it in GitHub Desktop.
MSAL in JavaScript
const msalConfig = {
auth: {
clientId: 'your-client-id',
authority: 'https://login.microsoftonline.com/common',
redirectUri: 'http://localhost:3000',
},
cache: {
cacheLocation: 'localStorage',
storeAuthStateInCookie: true,
}
};
const loginRequest = {
scopes: ["user.read"]
};
const pca = new msal.PublicClientApplication(msalConfig);
async function signIn() {
const authResult = await pca.loginPopup(loginRequest);
console.log('Access Token: ', authResult.accessToken);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment