Skip to content

Latest commit

 

History

History
79 lines (55 loc) · 4.37 KB

app-service-mobile-android-get-started-users.md

File metadata and controls

79 lines (55 loc) · 4.37 KB
title description services documentationcenter author manager editor ms.assetid ms.service ms.workload ms.tgt_pltfrm ms.devlang ms.topic ms.date ms.author
Add authentication on Android with Mobile Apps | Microsoft Docs
Learn how to use the Mobile Apps feature of Azure App Service to authenticate users of your Android app through a variety of identity providers, including Google, Facebook, Twitter, and Microsoft.
app-service\mobile
android
conceptdev
crdun
1fc8e7c1-6c3c-40f4-9967-9cf5e21fc4e1
app-service-mobile
mobile
mobile-android
java
article
11/16/2017
crdun

Add authentication to your Android app

[!INCLUDE app-service-mobile-selector-get-started-users]

Summary

In this tutorial, you add authentication to the todolist quickstart project on Android by using a supported identity provider. This tutorial is based on the Get started with Mobile Apps tutorial, which you must complete first.

Register your app for authentication and configure Azure App Service

[!INCLUDE app-service-mobile-register-authentication]

Add your app to the Allowed External Redirect URLs

Secure authentication requires that you define a new URL scheme for your app. This allows the authentication system to redirect back to your app once the authentication process is complete. In this tutorial, we use the URL scheme appname throughout. However, you can use any URL scheme you choose. It should be unique to your mobile application. To enable the redirection on the server side:

  1. In the Azure portal, select your App Service.

  2. Click the Authentication / Authorization menu option.

  3. In the Allowed External Redirect URLs, enter appname://easyauth.callback. The appname in this string is the URL Scheme for your mobile application. It should follow normal URL specification for a protocol (use letters and numbers only, and start with a letter). You should make a note of the string that you choose as you will need to adjust your mobile application code with the URL Scheme in several places.

  4. Click OK.

  5. Click Save.

Restrict permissions to authenticated users

[!INCLUDE app-service-mobile-restrict-permissions-dotnet-backend]

  • In Android Studio, open the project you completed with the tutorial Get started with Mobile Apps. From the Run menu, click Run app, and verify that an unhandled exception with a status code of 401 (Unauthorized) is raised after the app starts.

    This exception happens because the app attempts to access the back end as an unauthenticated user, but the TodoItem table now requires authentication.

Next, you update the app to authenticate users before requesting resources from the Mobile Apps back end.

Add authentication to the app

[!INCLUDE mobile-android-authenticate-app]

Cache authentication tokens on the client

[!INCLUDE mobile-android-authenticate-app-with-token]

Next steps

Now that you completed this basic authentication tutorial, consider continuing on to one of the following tutorials:

  • Add push notifications to your Android app. Learn how to configure your Mobile Apps back end to use Azure notification hubs to send push notifications.
  • Enable offline sync for your Android app. Learn how to add offline support to your app by using a Mobile Apps back end. With offline sync, users can interact with a mobile app—viewing, adding, or modifying data—even when there is no network connection.