3

So I am trying to sync to google docs, without having to ask the user for his credentials. I use this code to get an auth-token:

AccountManager mgr = AccountManager.get(activity);
authToken = mgr.blockingGetAuthToken(account, DocsService.DOCS_SERVICE, true);

This returns a auth-token that looks well-formated. So on my DocsService I run:

service.setAuthSubToken(authToken);

However, when I try to use the API I just get a AuthenticationException. Any ideas on how to approach this error?

edit: I do have the USE_CREDENTIALS permission.

pgsandstrom
  • 14,361
  • 13
  • 70
  • 104

3 Answers3

6

The problem is that the returned token is a ClientLogin token, not an AuthSub token. An even bigger problem is that the GData Java Client library does not officially support Android. We recently added a note on the home page of the GData Java Client library that for Android we recommend Google API Client Library for Java instead.

Two samples come up mind that would be helpful for you for getting started with Google API Client Library for Java: calendar-v2-atom-android-sample and docs-v3-atom-oauth-sample

Disclosure: I am an owner of both the GData Java Client library and Google API Client Library for Java projects.

Yaniv Inbar
  • 1,409
  • 9
  • 10
  • thx lol, I'll try to use that library instead. I also made a request for more extensive google docs-samples, it would really help :) – pgsandstrom Nov 05 '10 at 12:50
  • 1
    Sorry, but your links for examples are not working. Could you post any new links? – Aram Mar 12 '12 at 09:19
2

You might also want to take a look at Yaniv's Google I/O 2011 Session slides/video for reference on how to access the GData APIs on Android.

http://www.google.com/events/io/2011/sessions/best-practices-for-accessing-google-apis-on-android.html

Nitin Jain
  • 86
  • 2
0

As Yaniv explained, Gdata Lib doesn't work in Android. I wasted several hour with no result. It looks pretty weird, its Google's product and still not supported in their own platform (Android).

Anyway I have developed a Client Library which works on Android. I am managing the project on Google Code- http://code.google.com/p/google-spreadsheet-lib-android/

You can give a try.

Lucifer
  • 29,392
  • 25
  • 90
  • 143
user542954
  • 512
  • 4
  • 2
  • Yeah, well, Google's policy of treating everyone and everything as equal means that they end up shooting themselves in the foot when it comes to having one of their projects work with another project. (IE, Google Services working well with Android. That'd be unfair to iOS and Windows and Mac OS. No, the support for every platform has to suck equally.) – ArtOfWarfare Sep 11 '12 at 13:16