When Windows Azure mobile services originally launched ,the integration of node.js and to Azure Table Storage was not as fast than using .Net. I wanted also to reduce the costs and be billed only for a website or mobile service, not both.

Of course now this has changed, and now you can combine api, mobile and web resources and be billed for a single unit.

This lead me to investigate the internals of WAMS and its Zumo implementation, and created Zumo.Sharp.

Find in it GitHub: https://github.com/juanfranblanco/ZumoSharp

So what is Zumo.Sharp?

You love Windows Azure Mobile Services but you wish:

  • You could integrate your current web site with the Javascript, .Net, IOS and Android Azure Mobile Service Client and also integrate with Azure Mobile Services through the same authentication mechanism.
  • Future proof the integration with WAMS server for your new website and / or mobile application by leveraging the client and authentication.

What it does

  • Decrypts and verifies (using the same keys) authentication tokens generated by Azure Mobile Services
  • Authorisation of web api calls using said tokens
  • Generates tokens that can be shared with Azure mobile services
  • Authentication providers: Facebook.
  • Integration example of Mobile Service client with our custom api

Demo Example

Warning

Please ensure you use HTTPS when exchanging tokens

Azure mobile services

  • Source: https://github.com/Azure/azure-mobile-services
  • Documentation: http://azure.microsoft.com/en-us/documentation/services/mobile-services/

Quick instructions setup of the demo project

In Zumo.Sharp.Demo change the following configurations:

Web.Config / Server

Key Description
ApplicationMasterKeyhis is your Azure Mobile Services Master Key
ApplicationKeyThis is your application key, used as well in the client
FacebookAppIdFacebook app id, only used if you are authenticating here instead of WAMS
FacebookSecret Facebook secret, only used if you are authenticating here instead of WAMS
JWTExpiryInMinutesWhen do you want the token to expire, only used if you are authenticating here instead of WAMS

Client / Angularjs

Zumo.Sharp.Demo.Web / static / js / init.js

angular.module("ZumoDemo") 
     .config(function ($FBProvider) { 
          $FBProvider.setInitParams({ 
              appId: 'YourFacebookAppId' 
        }); 
    }); 
 
Zumo.Sharp.Demo.Web / static / js / services / mobileServiceClient.js

We have 2 mobile services clients (for demo purposes) one pointing to Azure and the other to the web api


angular.module("ZumoDemo").factory("mobileServiceClient", [function () {
    var MobileServiceClient = WindowsAzure.MobileServiceClient;
    var client = new WindowsAzure.MobileServiceClient(
    "https://yourazuremobileservice.azure-mobile.net/",
    "YourWAMSAPIKEY"
);
    return client;
}]);

angular.module("ZumoDemo").factory("mobileServiceClientWebApi", [function () {
    var MobileServiceClient = WindowsAzure.MobileServiceClient;
    var client = new WindowsAzure.MobileServiceClient(
    "/",
    "YourWAMSAPIKEY"
);
    return client;
}]);

WAMS Api

Create an Api call in Azure Mobile Services call "demo" so we can and use this as get:


exports.get = function(request, response) {
    response.send(statusCodes.OK, [
    {
        CustomerId: "1",
        Name: "Azure Mobile Services connection"
    },
    {
        CustomerId: "2",
        Name: "Azure Mobile Services connection"
    }
    ]
);
};

Quick overview

Zumo.Sharp.Demo.Web / Controllers / ZumoSharpDemoLoginController.cs

To support Facebook authentication it inherits from the generic LoginController implemented in ZumoSharp / Zumo.Sharp.AspNet / Controllers / LoginController.cs to support facebook authentication.

Zumo.Sharp.Demo.Web / Controllers / DemoController.cs

Demo controller has the attribute Zumo.Sharp.AspNet.ZumoAuthorisationFilter to enable Zumo authorisation checks.