domenica, febbraio 06, 2011

Connet an Android app to Google App Engine - Authenticated !

Sometime ago I read a very interesting post on Nick'blog: "Authenticating against App Engine from an Android app"  http://blog.notdot.net/2010/05/Authenticating-against-App-Engine-from-an-Android-app
The code was very intersting but I need to refactor a bit and I'd like to add some "utility" method.
Also I added a way to automatically invalidate old Auth token and get a new one.

My code (very alpha... I'm still working on it...) is here:
http://code.google.com/p/fhpublicstuff/source/browse/test/GAEConnector/GAEConnector.java

[Update: it manages http and https connections to GAE]

Usage:


// ....
_gaeConnector = new GAEConnector(null, "http://AAAAAAAA.appspot.com");
if (!_gaeConnector.Authenticate(MyTest.this)) {
  message = "***AUTHENTICATION ERROR***";
}
// .....
if (_gaeConnector.isAuthenticated()) {
  int httpStatusCode = _gaeConnector.GETContent("/myurl", true, true);
  if (httpStatusCode == 200) {
    String content = _gaeConnector.getLastContent();
    // ....

Nessun commento: