采用Android的AccountManager得到的authToken的GDATA [英] Using Android AccountManager to get authtoken for gdata

查看:177
本文介绍了采用Android的AccountManager得到的authToken的GDATA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我想同步到谷歌文档,而不必问他的凭据。我用这个code,以获得身份验证令牌:

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);

这将返回一个身份验证令牌看起来很好格式化。所以,在我的DocsService我运行:

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

service.setAuthSubToken(authToken);

然而,当我尝试使用API​​我刚拿到的AuthenticationException。关于如何处理此错误的任何想法?

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

编辑:我确实有USE_CREDENTIALS权限

edit: I do have the USE_CREDENTIALS permission.

推荐答案

的问题是,返回的标记是一个的ClientLogin令牌,而不是一个的AuthSub令牌。一个更大的问题是GData的Java客户端库并不正式支持Android。我们最近增加了一个注意,对于Android,我们推荐的GData Java客户端库的主页上谷歌的API客户端库对Java 的吧。

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.

两个样品拿出记住,将是开始使用谷歌API客户端库对Java对你有帮助:<一href="http://samples.google-api-java-client.google$c$c.com/hg/calendar-v2-atom-android-sample/instructions.html?r=default">calendar-v2-atom-android-sample和<一href="http://samples.google-api-java-client.google$c$c.com/hg/docs-v3-atom-oauth-sample/instructions.html?r=default">docs-v3-atom-oauth-sample

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

披露:我无论是GData的Java客户端库和谷歌的API客户端库的Java项目的所有者

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

这篇关于采用Android的AccountManager得到的authToken的GDATA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆