Skip to content

pixmob/appengineclient

Repository files navigation

AppEngine Client for Android

Copyright (C) 2011 Pixmob (http://github.com/pixmob)

If you consume web services hosted on AppEngine, this project is for you! The class AppEngineClient makes your web requests authenticated with a Google user account. The user do not have to enter his password: an authentication token is generated by the Android framework when the user grants its permission. The authentication is automatically made before executing your requests, even when the authentication cookie becomes invalid.

Usage

Making authenticated web requests on AppEngine is easy.

String gaeHost = "myapp.appspot.com";
String account = "johndoe@gmail.com";
DefaultHttpClient httpClient = new DefaultHttpClient();
AppEngineClient gaeClient = new AppEngineClient(context, gaeHost, httpClient, account);

HttpGet req = new HttpGet("http://myapp.appspot.com/hello");
try {
    gaeClient.execute(req);
} catch(AppEngineAuthenticationException e) {
	if(e.isAuthenticationPending()) {
		// the user should grant its permission to use his account:
		// an item in the notification bar will invite him to accept
		Log.i(TAG, "Waiting for user permission: try later");
	} else {
	    // authentication failed or service unavailable:
	    // call e.getReason() to know about details
		throw e;
	}
} finally {
    gaeClient.close();
}

The following Android permissions are required in your application when using this library:

  • android.permission.USE_CREDENTIALS,
  • android.permission.INTERNET.

A demo is available if you want to try this library with a real Android application (see demo in the source tree).

License

All of the source code in this project is licensed under the Apache 2.0 license except as noted.

How to use this library in my project?

This project is actually a library project. See this page for using a library in your Android application.

You have two choices for using this library:

  • use a JAR library: click on DOWNLOAD and put the JAR file in your libs directory;
  • use AppEngineClient as a library project: use git to clone this repository and link it as a library project (you can easily follow updates).

About

Android library for authenticating web requests on AppEngine

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages