Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


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
Source: https://github.com/aerogear/aerogear-android-cookbook/tree/master/AuthExamples

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 org.jboss.aerogear.android.cookbook.authexamples.Constants#URL_BASE 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
pipe.read(new 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