WL APIを使用してシングルサインオンを実装しましたが、Azure Mobile Servicesの優れた認証機能を使用するには、その上にmobileService.loginを呼び出す必要があることに最近気づきました。
私はこのチュートリアルに従いました
そして、このコードを追加しました:
var login = function () {
return new WinJS.Promise(function (complete) {
WL.init();
WL.login({ scope: ["wl.signin", "wl.basic", "wl.birthday", "wl.emails"] }).then(function (result) {
session = result.session;
WinJS.Promise.join([
WL.api({ path: "me", method: "GET" }),
mobileService.login("microsoftaccount", session.authentication_token)
]).done(function (results) {
var profile = results[0];
var mobileServicesUser = results[1];
var title = "Welcome " + profile.first_name + "!";
var message = "You are now logged in as: " + mobileServicesUser.userId;
var dialog = new Windows.UI.Popups.MessageDialog(message, title);
dialog.showAsync().done(complete);
});
}, function (error) {
session = null;
var dialog = new Windows.UI.Popups.MessageDialog("You must log in.", "Login Required");
dialog.showAsync().done(complete);
});
});
}
ただし、この行では
mobileService.login("microsoftaccount", session.authentication_token)
私のsession.authentication_tokenは未定義です。(私はaccess_tokenを持っています)
トークンを渡さないと、アプリを起動するたびにサインインするように求められます。これにより、統合サインオンの目的が無効になります。
何か案は?