Step by step – Creating an authenticated Azure mobile app with Xamarin walkthrough

In a previous post I showed how to setup to Azure mobile app backend C# service to use custom authenticated with Asp.Net Identity from an existing user database. If you’ve not done that yet please follow that post first.

Now that we have the back end ready for custom authentication we need to configure the app. In our example we’ll be modifying the quick starts Xamarin sample you get from Azure:


You need to create a new login screen and set it is as default. Once done add username and password fields and a sign in button. In the button click event you need:

private MobileServiceClient client;
client = new MobileServiceClient(applicationURL);
var credentials = new JObject
				["email"] = Helper.RetrieveString("Username"),
				["password"] = Helper.RetrieveString("Password")
var user = await TodoItemManager.DefaultManager.CurrentClient.LoginAsync("custom", credentials);

The user field will now contain the token from the webservice. The Azure mobile service should will automatically add the token using X-Zumo-Auth headers to each call for data. You wont need to do anything.