我正在尝试windows live使用他们的 javascript API 实现登录。我将此文档作为示例并使用以下代码:
WL.Event.subscribe("auth.login", onLogin);
WL.init({
client_id: 'my client id',
redirect_uri: 'redirect uri',
scope: ["wl.signin", "wl.basic"],
response_type: "token"
});
WL.ui({
name: "signin",
element: "signin"
});
function onLogin(session) {
if (!session.error) {
WL.api({
path: "me",
method: "GET"
}).then(
function (response) {
console.log(response);
document.getElementById("info").innerText =
"Hello, " + response.first_name + " " + response.last_name + "!";
},
function (responseFailed) {
document.getElementById("info").innerText =
"Error calling API: " + responseFailed.error.message;
}
);
}
else {
document.getElementById("info").innerText =
"Error signing in: " + session.error_description;
}
}
上面的代码正在返回id,和其他字段name,但我也想通过在. 我浏览了WL.init 文档,并没有提到和值。有什么办法可以得到这两个字段?emailprofile picture urlgoogle+emailscopeemailprofile picture url scope