上传文件 - DocumentList.java示例,提供“需要授权”错误

时间:2012-11-14 21:20:03

标签: java file-upload google-api

我正在尝试将文件从桌面上传到Google云端硬盘。我在Google提供的CLIENT_ID示例中提供了CLIENT_SECRETDocumentList.java。当我作为java应用程序运行时,我收到以下错误:

return service.insert(buildUrl(URL_DEFAULT + URL_DOCLIST_FEED), newDocument);

代码:

oauthParameters.setOAuthConsumerKey(CLIENT_ID);
oauthParameters.setOAuthConsumerSecret(CLIENT_SECRET);    
oauthParameters.setScope("https://docs.google.com/feeds/");
DocsService service = new DocsService("wise");

错误:

com.google.gdata.util.AuthenticationException: Authorization required
    at com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataRequest.java:608)
    at com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(GoogleGDataRequest.java:564)
    at com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.java:560)
    at com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java:538)
    at com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java:536)
    at com.google.gdata.client.media.MediaService.insert(MediaService.java:400)
    at com.DocumentList.uploadFile(DocumentList.java:538)
    at com.DocumentList.login(DocumentList.java:230)
    at com.DocumentList.main(DocumentList.java:546)

0 个答案:

没有答案