(予め)本記事はプレビュー版の環境に基づいて書かれています。
Windows 1o Desctop Build 10240
Windows 1o Mobile Build 10166
Visual Studio 2015 RC
製品版では内容と異なる可能性もあります。
今回もUWPアプリのサンプルを動かしてみます。
前回から引き続きアルファベット順に上から。今回はAccountsプロジェクトです。
アカウントというあたりで、前回のログインユーザーのアカウント情報がなぜか取れなかった件が頭に浮かびますが、今回はMicrosoftアカウントでログインして、トークンを取得。Microsoftアカウントで利用できる様々なサービスと連携的な流れっぽいので一安心。
こういうサービスはトークンを取得するためのキーとかIDが必要だったりするんですが、
// To obtain Microsoft account tokens, you must register your application online // Then, you must associate the app with the store.const string (略) AccountClientId = "none"; const string StoredAccountKey = "accountid";
やっぱり必要そうですね。
まだストアからキーは取れなさそうなので、今回もサンプルコードだけ紹介。
SignInボタンを押すと以下のコードが実行されログインページが表示されます。
AccountsSettingsPane.Show();
SNS連携で良くあるSNS側のページに一旦遷移してトークンを取得して戻ってくるパターンですね。
AccountsSettingsPaneには事前にイベントハンドラ―が設定してあり、
AccountsSettingsPane.GetForCurrentView().AccountCommandsRequested += OnAccountCommandsRequested;
最後にトークンを取得しに行くのですが・・・
WebTokenRequest webTokenRequest = new WebTokenRequest(Provider, Scope, ClientID); // If the user selected a specific account, RequestTokenAsync will return a token for that account. // The user may be prompted for credentials or to authorize using that account with your app // If the user selected a provider, the user will be prompted for credentials to login to a new account WebTokenRequestResult webTokenRequestResult = await WebAuthenticationCoreManager.RequestTokenAsync(webTokenRequest);
キーなどを設定してないので今のところ、エラーになります。
Please give us your valuable comment