Я новичок в Ionic и хочу аутентифицировать пользователя с помощью Azure. Поэтому я использую MS ADAL Ionic Native в своем проекте. Я не мог найти подходящий пример в Интернете. Вот мой app.component.ts
import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { MSAdal, AuthenticationContext, AuthenticationResult } from '@ionic-
native/ms-adal';
import { HomePage } from '../pages/home/home';
@Component({
templateUrl: 'app.html'
})
export class MyApp {
rootPage:any = HomePage;
constructor(private msAdal: MSAdal,platform: Platform, statusBar:
StatusBar, splashScreen: SplashScreen) {
platform.ready().then(() => {
let authContext: AuthenticationContext=
this.msAdal.createAuthenticationContext('https://login.windows.net/common');
authContext.acquireTokenAsync('https://graph.windows.net', '[My-appID]', 'http://localhost:8000')
.then((authResponse: AuthenticationResult) => {
console.log('Token is' , authResponse.accessToken);
console.log('Token will expire on', authResponse.expiresOn);
})
.catch((e: any) =>
alert(e));
statusBar.styleDefault();
splashScreen.hide();
});
}
}
Я получаю следующую ошибку.
TypeError: Неверный тип для параметра "userId" файла AuthenticationContext.acquireTokenAsync: ожидаемая строка, но получена функция.