关于appengine的Google Spreadsheets

时间:2013-07-14 04:23:05

标签: google-app-engine google-spreadsheet-api

我正在尝试阅读关于appengine的电子表格:

List<String> scopes = Arrays.asList("https://spreadsheets.google.com/feeds");
AppIdentityService appIdentity = AppIdentityServiceFactory.getAppIdentityService();
AppIdentityService.GetAccessTokenResult accessToken = appIdentity.getAccessToken(scopes);

Credential creds = new Credential(BearerToken.authorizationHeaderAccessMethod());
creds.setAccessToken(accessToken.getAccessToken());

SpreadsheetService ss = new SpreadsheetService("DBM4G-demo");
ss.setOAuth2Credentials(creds);

我遇到的问题是setOAuth2Credentials不是一个类(至少eclipse说它不是,我无法编译)。我在我的项目中包含了gdata-spreadsheets-3.0.jar。任何想法??

1 个答案:

答案 0 :(得分:0)

OAuth问题 Google DrEdit教程是解决Google广告系列/电子表格等OAuth问题的好方法。这是我能够找到的最佳OAuth教程。

电子表格连接代码

SpreadsheetService spreadsheetService = null;
spreadsheetService = new SpreadsheetService("mydomain.com.au-v0.2");
spreadsheetService.setHeader("Authorization", "Bearer " + accessToken);
spreadsheetService.setConnectTimeout(0);

(我将setConnectTimeout(0)添加到开发中,但怀疑我不再需要它。)