sign in with windows live connect, similar to Google's "postmessage"

216 views Asked by At

I have a "Sign in with Google" button in my web app, which opens the consent window, gets a code after the user logs in and sends it to my server, for server side validation. This is the Javascript code I use:

gapi.load('auth2', function() {
    auth2 = gapi.auth2.init({
        client_id: CLIENT_ID,
        scope: googleScopes
    });
});
$('#signInButtonGoogle').click(function() {
    auth2.grantOfflineAccess({'redirect_uri': 'postmessage', 'approval_prompt' : 'force'}).then(onGoogleSignIn);
});

I'm trying to implement a "Sign in with Outlook.com" button, which should do exactly the same, but it seem to lack some functionality which Google have, especially the 'redirect_uri': 'postmessage' redirect URI and 'approval_prompt' : 'force'.

This is my current Microsoft Live Connect Javascript code:

WL.Event.subscribe("auth.login", onMsnSignIn); <== never got to a point where this actually worked
WL.init({
    client_id: CLIENT_ID,
    redirect_uri: REDIRCT_URI, <== no 'postmessage' option :-(
    scope: "wl.signin",
    response_type: "code"
});
// this is instead of 'approval_prompt' : 'force', but I'm not sure it really works
WL.getLoginStatus(function(response) {
    if (response.status == 'connected') {
        WL.logout();
    }
});
$('#signInButtonLive').click(function () {
    WL.login({
        scope: msnScopes // additional scopes required
    }).then(
        // this works only when I have a session in another Microsoft site, like MSDN
        // but I want to force the user to sign in with the right Live ID
        function (session) {
            console.log(session);
            WL.api({
                path: "me",
                method: "GET"
            }).then(
                function (response) {
                    console.log(response)
                })
        },
        function (sessionError) {
            console.log('error');
        }
    );
});

So it there a way to have a similar functionality to Google sign in?

Are there alternatives to 'postmessage' and 'force' in MS Live?

Is it possible to achieve the same in the handler, pointed by the redirect_uri? I haven't found any example to this handler, and in addition to receiving and passing the code, it should close the consent window.

0

There are 0 answers