Building a mobile app? Need to know who logged in? Check out User Authentication in Azure Mobile Services

LogoWhether it’s Android, iOS, or Windows Phone, many apps need users to log in. Azure Mobile Services simplifies setting up user authentication in your app.

 

Azure mobile services has a number of features to make it easier to build really powerful mobile apps. One of those features is user authentication.

Many app developers have a need to identify their users. Maybe you are building a game and you want players to be able to challenge each other. Maybe you are building a gift registry app to help users put together birthday wish lists. Whatever the reason, Azure Mobile Services helps you add user authentication to your app.

You could write code to create accounts and passwords for users, store that information in a database table, and handle everything yourself, but a simpler solution is to have your user log in with an existing account such as Facebook, Microsoft, Twitter, or Google. If you register your app with one or more of those providers, you can allow a user to log in with an existing username and password, and the provider (e.g. Twitter) will provide you with information about the user who logged in. This is a popular solution when you need to know who is using your app. Azure Mobile Services simplifies the process of adding this capability to your application.

The Azure website has step by step tutorials on how to implement authentication using the Azure Mobile Services. There are different tutorials for different platforms/languages, so choose the one that helps you: Windows Store C#, Windows Store JavaScript, Windows Phone, iOS, Android, HTML

If you want the screenshots and code samples, go to the links above, but I will briefly explain the steps required to use the user authentication in Azure Mobile Services here.

In order to add user authentication to your app you need to

1. Create an Azure account

If you are a startup company you may qualify for BizSpark which includes Azure benefits.

If you are an instructor you may be able to get an Azure academic passes for the students in your class (no credit cards required).

Anyone can get a free Azure trial!

2. Get the Azure Mobile Services SDK

If you are a student, you can download the Azure SDK and Visual Studio Professional from DreamSpark, your one stop shop for development software.

If you are not a student, you can download the Azure SDK at the Azure website, just select Downloads from the menu.

 

3. Register your app for authentication and configure Mobile Services

Basically this means you have to register your app with an identity provider such as a Microsoft account, Facebook login, twitter login, or Google login. When you do this you will receive a client identity and secret values from the provider. You’ll need to go to the Azure management portal and enter this value so Azure Mobile Services can connect to the identity service.

4. Restrict table permissions to authenticated users

You can now specify that only authenticated users (users who have logged in using the provider you support) can access certain data in your application. You can control insert, update, delete, and read permissions. So you might allow a users who hasn’t log in to read data, but not modify data.

5. Add authentication to the app

You will need to add code to your app that allows users to login. This is usually invoked from something like a Click event on a login button.The code you use will vary depending on the platform you use, but if you go to the tutorials above you can find code samples for adding authentication.

Happy coding!