2012-06-04 64 views
0

我試圖找回這樣的文件:錯誤在谷歌文檔API文檔導出

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"}

不爲什麼,如果我的客戶端經過驗證,希望有人能幫忙,提前致謝。

+0

您可以添加實際發送請求的行嗎? –

+0

在這一行MediaSource ms = client.getMedia(mc);正在發送請求。 – Alexander

回答

0

也許這將幫助:

  1. 替換獲得的URI 的docId參數與ID參數

    contentUri = "https://docs.google.com/feeds/download/documents/export/Export?id=" + entry.getDocId() + "&exportFormat=txt&format=txt"; 
    
  2. 直接使用的方法(這是建議)

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