我是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: AuthenticationContext.acquireTokenAsync的参数"userId"类型错误:期望为字符串,但实际传入的是函数。