Calendar API and OAuth

*爱你&永不变心* 提交于 2019-12-25 01:19:35

问题


From a lot of examples on the web, i am trying out a calendar application on my own. These examples used GoogleAccessProtectedResource during the calendar build. But when I tried it it says its been deprecated. Can someone please tell me what is the correct way to implement this?

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

回答1:


The Javadocs for the current version of the Google API JAVA Client library say this:

Deprecated. (scheduled to be removed in 1.11) Use GoogleCredential

See the Google OAuth wiki pages for an example on how to use it:

GoogleCredential credential = new GoogleCredential().setAccessToken(accessToken);
Plus plus = Plus.builder(new NetHttpTransport(), new JacksonFactory())
    .setApplicationName("Google-PlusSample/1.0")
    .setHttpRequestInitializer(credential)
    .build();


来源:https://stackoverflow.com/questions/11543084/calendar-api-and-oauth

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!