开发者

Using Android AccountManager to get authtoken for gdata

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(ac开发者_如何学Ccount, 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.


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.


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜