私のアプリケーションでAzure Active Directory認証を取得しようとしています。私のionic-frameworkアプリケーションで虹彩広告許可フローを起動できません
を使用して、私のAzureのディレクトリアプリケーションを設定するための手順に従っている私はまた、アプリケーションを作成し、ログインを呼び出しIonicframework documentation
HTML要素()で見つかったコード追加しました:
を<button ion-button (click)="login()">Login</button>
マイコード:home.ts
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { ToastController } from 'ionic-angular';
import { MSAdal, AuthenticationContext, AuthenticationResult } from '@ionic-native/ms-adal';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
ready = false;
authority = "https://login.microsoftonline.com/common";
redirectUri = "http://IonicAuthenticationTest";
resourceUri = "https://graph.windows.net";
clientId = "Left out application id for security reasons";
graphApiVersion = "2013-11-08";
authContext : AuthenticationContext;
constructor(public navCtrl: NavController, private msAdal: MSAdal, private tc: ToastController) {
this.authContext = this.msAdal.createAuthenticationContext(this.authority);
}
ionViewDidLoad() {
this.ready = true;
}
login() {
this.authContext.acquireTokenAsync(this.resourceUri, this.clientId, this.redirectUri)
.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));
}
}
私はionic proを使用してアプリケーションをビルドしてテストします。基本的に私がログインボタンをクリックすると、何も起こっていない、ブラウザが開いていない、何もない。定義されていないエラーで「キャッチ」にまっすぐ進みます。
何か不足していますが、何ですか?
あなたのお役に立っていただきありがとうございます!
マイAuthorizationContextステー' –