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 |
[!INCLUDE app-service-mobile-selector-get-started-users]
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.
[!INCLUDE app-service-mobile-register-authentication]
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:
-
In the Azure portal, select your App Service.
-
Click the Authentication / Authorization menu option.
-
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. -
Click OK.
-
Click Save.
[!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.
[!INCLUDE mobile-android-authenticate-app]
[!INCLUDE mobile-android-authenticate-app-with-token]
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.