Skip to content

Instantly share code, notes, and snippets.

@cjvandyk
Created April 19, 2023 12:29
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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