Created
April 19, 2023 12:29
-
-
Save cjvandyk/25367b7d0ffb738ca10b46ec5d91569d to your computer and use it in GitHub Desktop.
MSAL in JavaScript
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
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