MS ADAL Integration

Hi all,

Has anyone managed to successfully integrate the Ionic Native MS ADAL?
I am getting a few errors and I am unsure what I am doing wrong.

home.ts

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { MSAdal, AuthenticationContext, AuthenticationResult } from '@ionic-native/ms-adal';


@Component({
  selector: 'page-home',
  templateUrl: 'home.html' 
})
export class HomePage {

  userId: string = ' [ my email ] ';
  constructor(public navCtrl: NavController, private msAdal: MSAdal) {

    let authContext: AuthenticationContext = this.msAdal.createAuthenticationContext('https://login.windows.net/common');

    authContext.acquireTokenAsync('https://graph.windows.net', ' [ Application ID ] ', 'http://localhost:8000/', this.userId)
      .then((authResponse: AuthenticationResult) => {
        console.log('Token is' , authResponse.accessToken);
        console.log('Token will expire on', authResponse.expiresOn);
      })
      .catch((e: any) => 
      console.log('Authentication failed', e)
    );
      
  }

}

I am getting “Wrong type for parameter “extraQueryParameters” of AuthenticationContext.acquireTokenAsync: Expected String, but got Function.”

"Authentication failed TypeError: “Wrong type for parameter “extraQueryParameters” of AuthenticationContext.acquireTokenAsync: Expected String, but got Function.”

Any help is much appreciated :slight_smile:

Hi,

I have the same error last month.

You need to add null for the last paramter is not a optional paramter.

authContext.acquireTokenAsync('https://graph.windows.net', ' [ Application ID ] ', 'http://localhost:8000/', this.userId, null)

Thank you that worked. I just didn’t know that the library only works on a device or simulator.