Implementing SSO login with ADAL and JWT on an ionic app

Hi everyone !

I’m trying to Implemente SSO login with ADAL and JWT on an ionic app.

I’m using Angular 5.2.10 and Ionic v3.

This is my auth.service.ts :

I import :

import { Injectable } from '@angular/core';
import { JwtHelperService } from '@auth0/angular-jwt';
import { Platform} from 'ionic-angular';
import { MSAdal, AuthenticationContext, AuthenticationResult } from '@ionic-native/ms-adal';
import { environment as env } from '../environments/environment';

And I’m pretty sure I’ve no problem on my environment file because I already try it on an other app.

Then I’ve a problem on my authenticate function :

@Injectable()
export class AuthService {
  constructor(
    private msAdal: MSAdal,
    private jwtHelper: JwtHelperService,
    private platform: Platform,
  ) {
    console.log("auth.service.ts constructor");
    platform.ready().then(() => {
      console.log('Activate ADAL logger GSA');
    });
  }


  public async authenticate(): Promise<boolean> {
    console.log('GSA authenticate');
    await this.platform.ready();
    console.log('Called authenticate');
    const authContext = this.msAdal.createAuthenticationContext(
      env.adAuthority,
      false
    );
    authContext.validateAuthority = false;
    // Attempt to authorize user silently
    try {
      console.log('Trying to authorize user silently');
      const silentAuthResult = await authContext.acquireTokenSilentAsync(
        env.adResourceUri,
        env.adClientId,
        undefined
      );
      console.log('Silent Auth result:', silentAuthResult);
      return true;
    } catch (err) {
      console.log(
        'Cannot authorize user silently, trying to launch login process'
      );
      try {
        const authResult = await authContext.acquireTokenAsync(
          env.adResourceUri,
          env.adClientId,
          env.adRedirectUri,
          undefined,
          undefined
        );
        console.log('Auth Result:', authResult);
        return true;
      } catch (err) {
        console.error('Cannot authorize user silently. User unauthorized or no connectivity to the authentication provider: ', err);
        return false;
      }
    }
  }    

I’m getting this error :

Error: Uncaught (in promise): TypeError: Cannot set property 'validateAuthority' of undefined
TypeError: Cannot set property 'validateAuthority' of undefined
    at AuthenticationContext.set [as validateAuthority] (http://localhost:8100/build/vendor.js:126569:39)
    at AuthService.<anonymous> (http://localhost:8100/build/main.js:1407:55)```

I'm sorry if it's a dumb question, I'm a beginner, but can someone please help me with this ?

Thanks a lot !