2017-11-13 8 views
0

私のアプリケーションでAzure Active Directory認証を取得しようとしています。私のionic-frameworkアプリケーションで虹彩広告許可フローを起動できません

私はWindows documentation

を使用して、私の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を使用してアプリケーションをビルドしてテストします。基本的に私がログインボタンをクリックすると、何も起こっていない、ブラウザが開いていない、何もない。定義されていないエラーで「キャッチ」にまっすぐ進みます。

何か不足していますが、何ですか?

あなたのお役に立っていただきありがとうございます!

+0

マイAuthorizationContextステー' –

答えて

0

ブラウザからIonic View/Ionic Proをテストすることはできません。あなたはエミュレータまたは実際のデバイスからテストする必要があります。 これは私がトークンをacquring前authContextをログインしたときに、私が得るものです:: `[例外:例外TypeError:AuthenticationContext.getで未定義のプロパティを読み取ることができません「権威」[]権威として私が思う未定義

関連する問題