1- import { AuthenticationContext } from 'adal -node' ;
1+ import * as msal from '@azure/msal -node' ;
22
3- import { adalConfiguration } from '../constants' ;
3+ import { msalConfiguration } from '../constants' ;
44
55const resource = 'https://graph.microsoft.com/' ;
66
@@ -9,10 +9,10 @@ const resource = 'https://graph.microsoft.com/';
99 * @return {string } a fully formed uri with which authentication can be completed.
1010 */
1111export function getAuthUrl ( ) {
12- return adalConfiguration . authority + '/oauth2/authorize'
13- + '?client_id=' + adalConfiguration . clientID
12+ return msalConfiguration . authority + '/oauth2/authorize'
13+ + '?client_id=' + msalConfiguration . clientID
1414 + '&response_type=code'
15- + '&redirect_uri=' + adalConfiguration . redirectUri ;
15+ + '&redirect_uri=' + msalConfiguration . redirectUri ;
1616}
1717
1818/**
@@ -21,14 +21,14 @@ export function getAuthUrl() {
2121 * @param {AcquireTokenCallback } callback The callback function.
2222 */
2323export function getTokenFromCode ( code ) {
24- const authContext = new AuthenticationContext ( adalConfiguration . authority ) ;
24+ const authContext = new msal . AuthenticationContext ( msalConfiguration . authority ) ;
2525 return new Promise ( ( resolve , reject ) => {
2626 authContext . acquireTokenWithAuthorizationCode (
2727 code ,
28- adalConfiguration . redirectUri ,
28+ msalConfiguration . redirectUri ,
2929 resource ,
30- adalConfiguration . clientID ,
31- adalConfiguration . clientSecret ,
30+ msalConfiguration . clientID ,
31+ msalConfiguration . clientSecret ,
3232 ( err , token ) => {
3333 if ( err ) {
3434 reject ( err ) ;
@@ -41,9 +41,9 @@ export function getTokenFromCode(code) {
4141}
4242
4343export function getAppOnlyToken ( ) {
44- const authContext = new AuthenticationContext ( adalConfiguration . authority . replace ( 'common' , adalConfiguration . tenantID ) ) ;
44+ const authContext = new AuthenticationContext ( msalConfiguration . authority . replace ( 'common' , msalConfiguration . tenantID ) ) ;
4545 return new Promise ( ( resolve , reject ) => {
46- authContext . acquireTokenWithClientCredentials ( resource , adalConfiguration . clientID , adalConfiguration . clientSecret , ( err , token ) => {
46+ authContext . acquireTokenWithClientCredentials ( resource , msalConfiguration . clientID , msalConfiguration . clientSecret , ( err , token ) => {
4747 if ( err ) {
4848 reject ( err ) ;
4949 } else {
0 commit comments