Azure Active Directory OAuth エンドポイントに対して認証する必要がある Windows Phone 8.1 アプリ (Windows ランタイム) を作成しています。OAuth トークンを取得するための認証マネージャーとして、WP81 nuget パッケージの ADAL を使用しています。
私が苦労している問題は、電話ページのライフサイクルでさまざまな ADAL ログイン メソッドを呼び出す必要がある場所です。今、私はイベントに電話AuthenticationContext.AquireTokenAndContine()
していPage.Loaded
ます。github サンプル コードで説明されているようにContinuationManager
、 、IWebAuthenticationContinuable
、およびイベントも実装しました。クライアントURIを取得するためにApp.Activated
も使用しています。Windows.Security.Authentication.Web.WebAuthenticationBroker.GetCurrentApplicationCallbackUri()
何をしても、次のエラーが引き続き発生します。私に何ができるかについての洞察はありますか?よろしくお願いいたします。
mscorlib.ni.dll で 'Microsoft.IdentityModel.Clients.ActiveDirectory.AdalException' が発生しましたが、ユーザー コードで処理されませんでした
追加情報: authentication_ui_failed: ブラウザー ベースの認証ダイアログが完了しませんでした
async void MainPage_Loaded(object sender, RoutedEventArgs e)
{
await LoadFromViewModel();
}
public async Task LoadFromViewModel()
{
// Try to get a token without triggering any user prompt.
// ADAL will check whether the requested token is in the cache or can be obtained without user itneraction (e.g. via a refresh token).
AuthenticationResult result = await authContext.AcquireTokenSilentAsync(this.viewModel.RESTApiResourceUri, this.viewModel.AzureADClientId);
if (result != null && result.Status == AuthenticationStatus.Success)
{
// A token was successfully retrieved. Get the To Do list for the current user
await viewModel.BindData();
}
else
{
// Acquiring a token without user interaction was not possible.
// Trigger an authentication experience and specify that once a token has been obtained the GetTodoList method should be called
authContext.AcquireTokenAndContinue(this.viewModel.RESTApiResourceUri, this.viewModel.AzureADClientId, this.viewModel.AzureADRedirectUri, AuthenticationSuceeded);
}
}