【问题标题】:Error exporting a document in google docs api在 google docs api 中导出文档时出错
【发布时间】:2012-06-07 12:38:34
【问题描述】:

我正在尝试检索这样的文档:

  client.setAuthSubToken(token);
  String contentUri = "https://docs.google.com/feeds/download/documents/Export?docID="+ entry.getDocId()
                            + "&exportFormat=txt&format=txt";

  MediaContent mc = new MediaContent();
  mc.setUri(contentUri);

  MediaSource ms = client.getMedia(mc);
  InputStream inStream = ms.getInputStream();

但是我得到了下一个错误:

com.google.appengine.repackaged.org.apache.http.impl.client.DefaultRequestDirector handleResponse ADVERTENCIA: Authentication error: Unable to respond to any of these challenges: {authsub=WWW-Authenticate: AuthSub realm="https://www.google.com/accounts/AuthSubRequest"}

如果我的客户已通过身份验证,请不要为什么,希望有人可以提供帮助,在此先感谢。

【问题讨论】:

  • 你能添加你实际发送请求的行吗?
  • 在这一行 MediaSource ms = client.getMedia(mc);正在发送请求。

标签: java oauth google-docs google-docs-api


【解决方案1】:

也许这会有所帮助:

  1. 将 docId 参数替换为 id 参数

    contentUri = "https://docs.google.com/feeds/download/documents/export/Export?id=" + entry.getDocId() + "&exportFormat=txt&format=txt";
    
  2. 直接使用获取uri的方法(推荐)

    String contentUri = ((MediaContent) entry.getContent()).getUri();
    contentUri = contentUri + "&exportFormat=txt&format=txt";
    

【讨论】:

    猜你喜欢
    • 2012-07-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多