我正在使用 login.live.com 登录或注销我的网络应用程序。当我尝试使用 javascript 中的 WL.Login() 登录时,它是成功的。但是当我尝试使用 WL.Logout() 注销时,它会重定向到再次登录。我尝试寻找并找到了这个。我的问题是,如何使用https://login.live.com/oauth20_logout.srf从 live ID 注销?
这是我的代码
WL.Event.subscribe("auth.login", onLogin);
WL.Event.subscribe("auth.sessionChange", onSessionChange);
WL.Event.subscribe("auth.logout", onLogout);
WL.init({
scope: ["wl.signin", "wl.basic", "wl.emails"],
client_id: "****************",
});
function signUserIn() {
WL.login();
}
document.write("<button onclick='signUserIn()'>Click here to sign in!</button>");
function onLogin(session) {
var session = WL.getSession();
if (session.error) {
document.getElementById('<%= LabelStatusLogin.ClientID %>').innerHTML =
"Error signing in: " + session.error;
}
else {
document.getElementById('<%= LabelStatusLogin.ClientID %>').innerHTML =
"Signed in.";
}
}
function onSessionChange() {
var session = WL.getSession();
if (session) {
document.getElementById('<%= LabelStatusLogin.ClientID %>').innerHTML =
"Session changed.";
}
else {
document.getElementById('<%= LabelStatusLogin.ClientID %>').innerHTML =
"Signed out or session error.";
}
}
function onLogout() {
window.location = "https://login.live.com/oauth20_logout.srf?client_id=*************&display=page&locale=en&redirect_uri=http%3A%2F%2Fexample.com%3A8182%2F&response_type=token&scope=wl.signin wl.basic wl.emails&state=redirect_type%3Dauth%26display%3Dpage%26request_ts%3D1354173175356%26response_method%3Durl%26secure_cookie%3Dfalse";
}
function signUserOut() {
WL.logout();
}
document.write("<button onclick='signUserOut()'>Click here to sign out!</button>");