Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
app Add logout when back per @jcesarmobile proposal Nov 10, 2016
gradle/wrapper Update Android Gradle Tools version Nov 7, 2016
.gitignore Adding AuthExamples Jan 5, 2015 Update gradle instruction Nov 10, 2016
build.gradle Update Android Gradle Tools version Nov 7, 2016
gradlew.bat Adding AuthExamples Jan 5, 2015
settings.gradle Adding AuthExamples Jan 5, 2015

Mobile app showing the AeroGear Auth feature on Android

Author: Summers Pittman (secondsun)
Level: Beginner
Technologies: Java, Android
Summary: A basic example of HTTP Authentication

What is it?

Auth project demonstrates how to integrate HTTP Basic or HTTP Digest authentication into applications.

This simple project consists of a simple authenticated REST GET call.

This application is run on an Android device or emulator. It also requires the Authentication Server be running.

How do I run it?

System Requirements


Edit to be the path of the application.

This application has an backend implementation in our Backend Cookbook and also an only version

In the case of a emulator and server are running on the same machine the URL will be

Build Application

$ cd /path/to/authExamples/
$ ./gradlew clean build

Running the app

To deploy, run and debug the application on an Android device attached to your system, on the command line enter the following:

$ cd /path/to/authExamples
$ ./gradlew installDebug

How does it work?

HowToUseHttpBasicAuthentication and HowToUseDigestAuthentication are two activities which create appropriate AuthenticationModules and associate them with Pipe objects. The UI provides buttons to log in, log out, and fetch data from the Authentication Server.

// Create a Authentication Module
HttpBasicAuthenticationConfiguration authenticationConfig = null;
try {
    authenticationConfig = AuthenticationManager
        .config("login", HttpBasicAuthenticationConfiguration.class)
        .baseURL(new URL(Constants.URL_BASE));
} catch (MalformedURLException e) {

AuthenticationModule module = authenticationConfig.asModule();

// Create the pipe
RestfulPipeConfiguration pipeConfig = PipeManager
    .config("beer", RestfulPipeConfiguration.class)
    .withUrl(new URL(Constants.URL_BASE + "/grocery/beers"));

Pipe<String> pipe = pipeConfig.forClass(String.class);

//use the pipe as normal YourCallback());


There are two regressions problems to be fixed:

  • AGDROID-349 - HttpDigest Module needs to be able to disable making a server call on logout
  • AGDROID-350 - HTTPBasic and HTTPDigest callbacks aren't triggered on the UI thread