Hi all,
I have an Android app that has to upload and synchronize data from and
to GAE. Currently I use Restlet to connect Android to GAE. This works
good (below my testcode). Now I want to authenticate the restlet
webservice via Google Account (Oauth), but do not know how. All my
tests were not successfully. There is no tutorial how to use oauth
with Restlet on Android and the API is not intuitive. I looked into
the following tutorial
http://blog.notdot.net/2010/05/Authenticating-against-App-Engine-from-an-Android-app
In this tutorial an httpclient is used to get a cookie and then an
authenticated http call is made.
I did not manage to map this to restlet. I even tried to set the
cookie gained from the http reques to the restlet request, but I did
not succeed.
My questions are simple:
1. Does anyone has experience with Android client side Restlet and
authenticating with Google Accounts and maybe has some reference to a
good tutorial or sample code?
3. Is there a better/easier solution than using Restlet, with better
documentation and android tutorial?
Here is my test code, that works without authenticating. Calling the
Google user service on server side
"userServiceManager.isUserLoggedIn()" always returns false (not
authenticated):
GAE side:
Server Application:
public class UploadServerApplication extends Application {
@Override
public Restlet createInboundRoot() {
Router router = new Router(getContext());
getConnectorService().getClientProtocols().add(Protocol.FILE);
router.attachDefault(UploadServerResource.class);
return router;
}
}
Resource:
UploadServerResource extends ServerResource implements UploadResource
{
public UploadResult upload(UploadData uploadData) {
UserService userServiceManager =
UserServiceFactory.getUserService();
boolean authenticated = userServiceManager.isUserLoggedIn(); <---
always false in my tests!
if (authenticated) { ... result.setSuccess(true); }
else { ...result.setSuccess(false); }
return result;
}
-------------------------------------------------------------------------
Android client side:
ClientResource cr = new ClientResource("http://192.168.1.4:8888/
upload");
UploadResource resource = cr.wrap(UploadResource.class);
UploadData uploadData = new UploadData();
...
UploadResult result = resource.uploadTrack(uploadData);
...
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en