Adding Live SDK to a Cordova/Ionic project that is using Azure mobile services

78 Views Asked by At

I have a Ionic/cordova project which I am trying to get Microsoft account auth hooked up using Azure mobile services.

Wanting to use the client flow.

If you look at this document about where it talks about adding auth using client flow with Microsoft account you will see sample code: https://learn.microsoft.com/en-us/azure/app-service-mobile/app-service-mobile-cordova-how-to-use-client-library#a-nameauthahow-to-authenticate-users

How would you be able to use the Live SDK in TypeScript? Is there anyway to import Live SDK into Cordova/Ionic project?

WL.login({ scope: "wl.basic"}).then(function (result) {
      client.login(
            "microsoftaccount",
            {"authenticationToken": result.session.authentication_token})
      .done(function(results){
            alert("You are now logged in as: " + results.userId);
      },
      function(error){
            alert("Error: " + err);
      });
});
1

There are 1 best solutions below

0
Jordan McDonald On

Figured this out yesterday.

You have to import in the index.html this script tag:

src="//js.live.net/v5.0/wl.js

Then just did 'declare var WL: any;'

Then "WL" is recognized in TypeScript. Didn't find that in any documents and looked at many.