0

从网上的很多例子中,我自己尝试了一个日历应用程序。这些示例在日历构建期间使用了GoogleAccessProtectedResource 。但是当我尝试它时,它说它已被弃用。有人可以告诉我实现这一点的正确方法是什么吗?

public static Calendar build(String accessToken) {
  HttpTransport transport = AndroidHttp.newCompatibleTransport();
  JacksonFactory jsonFactory = new JacksonFactory();
  GoogleAccessProtectedResource accessProtectedResource =
      new GoogleAccessProtectedResource(accessToken);
  ...
}
4

1 回答 1

0

当前版本的 Google API JAVA 客户端库的 Javadocs 是这样说的:

已弃用。(计划在 1.11 中删除)使用GoogleCredential

有关如何使用它的示例,请参阅Google OAuth wiki 页面:

GoogleCredential credential = new GoogleCredential().setAccessToken(accessToken);
Plus plus = Plus.builder(new NetHttpTransport(), new JacksonFactory())
    .setApplicationName("Google-PlusSample/1.0")
    .setHttpRequestInitializer(credential)
    .build();
于 2012-07-18T14:23:23.187 回答