I'm encountering an issue with the MSAL Node library where I'm getting a TypeError regarding request.deviceCodeCallback not being a function. Here are the details:
- Relevant Code:
I'm using the
acquireTokenByDeviceCodemethod from the MSAL Node library to perform device code flow authentication. Here's the relevant code snippet:
const response = await publicApplication.acquireTokenByDeviceCode(authCodeUrlParameters, (deviceCodeResponse) => {
console.log(deviceCodeResponse.message); // Here I'm logging the device code message
});
I've tried reviewing the documentation for MSAL Node and ensuring that my configuration is correct. I've also checked that the values for clientId, authority, and clientSecret are accurate. However, I'm still encountering this error.
This issue occurs specifically when using the device code flow authentication with MSAL Node. I'm developing a Node.js application and integrating with Microsoft Azure Active Directory for authentication purposes.
I followed this MS DOC to get an access token from the Device code flow in JavaScript.
Code :
I enabled the mobile and desktop flows in my Azure AD app as below.
Output :
It ran successfully as below:
Browser output:
I used the device login URL https://microsoft.com/devicelogin and the authentication code to log in from the browser as below.
I selected my account for login as below.
I successfully logged in using the Device code flow as below.
I successfully logged in from the device code flow and got the access token as shown below.