File tree Expand file tree Collapse file tree
1-Authentication/6-sign-in-node-cli-app/App Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- const { LogLevel } = require ( '@azure/msal-node' ) ;
1+ import { LogLevel } from '@azure/msal-node' ;
22
33/**
44 * Configuration object to be passed to MSAL instance on creation.
55 * For a full list of MSAL.js configuration parameters, visit:
66 * https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-node/docs/configuration.md
77 */
8- const msalConfig = {
8+ export const msalConfig = {
99 auth : {
10- clientId : 'Enter_the_Application_Id_Here ' ,
11- authority : 'https://Enter_the_Tenant_Subdomain_Here .ciamlogin.com/' ,
10+ clientId : '2e9d2f02-7eb8-4cc3-9bd8-5e67eff7b80b ' ,
11+ authority : 'https://TrialTenantkwFwHYij .ciamlogin.com/' ,
1212 } ,
1313 system : {
1414 loggerOptions : {
@@ -27,11 +27,11 @@ const msalConfig = {
2727 * For more information about OIDC scopes, visit:
2828 * https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-permissions-and-consent#openid-connect-scopes
2929 */
30- const loginRequest = {
30+ export const loginRequest = {
3131 scopes : [ ] ,
3232} ;
3333
34- module . exports = {
35- msalConfig : msalConfig ,
36- loginRequest : loginRequest ,
37- } ;
34+ // module.exports = {
35+ // msalConfig: msalConfig,
36+ // loginRequest: loginRequest,
37+ // };
Original file line number Diff line number Diff line change 22 * Copyright (c) Microsoft Corporation. All rights reserved.
33 * Licensed under the MIT License.
44 */
5- const { PublicClientApplication, InteractionRequiredAuthError } = require ( '@azure/msal-node' ) ;
6- const open = require ( 'open' ) ;
7- const { msalConfig, loginRequest } = require ( './authConfig' ) ;
5+ import { PublicClientApplication , InteractionRequiredAuthError } from '@azure/msal-node' ;
6+ import open from 'open' ;
7+ import { msalConfig , loginRequest } from './authConfig.js' ;
88
99// Before running the sample, you will need to replace the values in src/authConfig.js
1010
@@ -30,12 +30,14 @@ const pca = new PublicClientApplication(msalConfig);
3030
3131const acquireToken = async ( ) => {
3232 const accounts = await pca . getTokenCache ( ) . getAllAccounts ( ) ;
33+ console . log ( accounts ) ;
3334 if ( accounts . length === 1 ) {
3435 const silentRequest = {
3536 account : accounts [ 0 ] ,
3637 } ;
3738
3839 return pca . acquireTokenSilent ( silentRequest ) . catch ( ( e ) => {
40+ console . log ( e ) ;
3941 if ( e instanceof InteractionRequiredAuthError ) {
4042 return pca . acquireTokenInteractive ( tokenRequest ) ;
4143 }
@@ -46,6 +48,7 @@ const acquireToken = async () => {
4648 } ) ;
4749 return Promise . reject ( 'Multiple accounts found. Please select an account to use.' ) ;
4850 } else {
51+ console . log ( pca ) ;
4952 return pca . acquireTokenInteractive ( tokenRequest ) ;
5053 }
5154} ;
You can’t perform that action at this time.
0 commit comments