Android:Google Data API - 401 令牌无效错误

发布于 2024-10-27 05:44:12 字数 1777 浏览 4 评论 0原文

好吧,我尝试使用帐户管理器,但收到“401 令牌无效”错误。可能是什么原因。

调试日志

Account name = [email protected]
Token is : DQAAALIAAAAh-xxxxxxx
Starting Google DATA API loader-----------------
Inside Google Notebook loader-----------------
Setting Token : DQAAALIAAAAh-xxxxx
Url is : https://docs.google.com/feeds/default/private/full
Exception getting docs feed : 401 Token invalid
Done Google DATA API loader-----------------

示例代码:

Log.d("Main","\tInside GoogleDATA API -----------------");
    HttpTransport transport = new NetHttpTransport();
    GoogleHeaders headers = new GoogleHeaders();
    Log.d("Main","\tSetting Token : " + authToken);
    headers.setGoogleLogin(authToken);
    headers.gdataVersion="3.0";
    transport.defaultHeaders = headers;
    AtomParser parser = new AtomParser();
    parser.namespaceDictionary = Namespace.DICTIONARY;
    transport.addParser(parser);
    try {
        DocsUrl url = DocsUrl.forDefaultPrivateFull();
        DocumentListFeed feed = DocumentListFeed.executeGet(transport,url);
        List<DocumentListEntry> docs = feed.docs;
        Log.d("Main","\tDocs count = " + docs.size());
        for (Iterator iterator = docs.iterator(); iterator.hasNext();) {
            DocumentListEntry documentListEntry = (DocumentListEntry) iterator
                    .next();
            Log.d("Main","\t\tDocument title is : " + documentListEntry.title);
        }
    } catch (IOException e) {
            Log.d("Main","Exception getting docs feed : " + e.getMessage());
            //handleException(e);
    }
    Log.d("Main","\tDone GoogleDATA API -----------------");

Well, I tried using Account Manager and I am getting "401 Token Invalid" error. What can be the reason.

Debug Log

Account name = [email protected]
Token is : DQAAALIAAAAh-xxxxxxx
Starting Google DATA API loader-----------------
Inside Google Notebook loader-----------------
Setting Token : DQAAALIAAAAh-xxxxx
Url is : https://docs.google.com/feeds/default/private/full
Exception getting docs feed : 401 Token invalid
Done Google DATA API loader-----------------

Sample Code:

Log.d("Main","\tInside GoogleDATA API -----------------");
    HttpTransport transport = new NetHttpTransport();
    GoogleHeaders headers = new GoogleHeaders();
    Log.d("Main","\tSetting Token : " + authToken);
    headers.setGoogleLogin(authToken);
    headers.gdataVersion="3.0";
    transport.defaultHeaders = headers;
    AtomParser parser = new AtomParser();
    parser.namespaceDictionary = Namespace.DICTIONARY;
    transport.addParser(parser);
    try {
        DocsUrl url = DocsUrl.forDefaultPrivateFull();
        DocumentListFeed feed = DocumentListFeed.executeGet(transport,url);
        List<DocumentListEntry> docs = feed.docs;
        Log.d("Main","\tDocs count = " + docs.size());
        for (Iterator iterator = docs.iterator(); iterator.hasNext();) {
            DocumentListEntry documentListEntry = (DocumentListEntry) iterator
                    .next();
            Log.d("Main","\t\tDocument title is : " + documentListEntry.title);
        }
    } catch (IOException e) {
            Log.d("Main","Exception getting docs feed : " + e.getMessage());
            //handleException(e);
    }
    Log.d("Main","\tDone GoogleDATA API -----------------");

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

两仪 2024-11-03 05:44:12

您应该在此网站上了解它的工作原理 http://n01se.net/gmapez/start.html

you should see how it works on this website http://n01se.net/gmapez/start.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文