日历API和OAuth [英] Calendar API and OAuth

查看:291
本文介绍了日历API和OAuth的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从网络上有很多的例子,我想自己出去一个日历应用程序。这些例子中使用的 GoogleAccessProtectedResource 日历生成过程中。但是,当我尝试过它说,它已经去precated。有人可以告诉我什么是实现这个正确的方法是什么?

 公共静态日历版本(字符串的accessToken){
  HttpTransport运输= AndroidHttp.newCompatibleTransport();
  JacksonFactory jsonFactory =新JacksonFactory();
  GoogleAccessProtectedResource accessProtectedResource =
      新GoogleAccessProtectedResource(的accessToken);
  ...
}


解决方案

的Javadoc,<一个href=\"http://javadoc.google-api-java-client.google$c$c.com/hg/1.10.3-beta/index.html?com/google/api/client/googleapis/auth/oauth2/draft10/GoogleAccessProtectedResource.html\"相对=nofollow>谷歌的API Java客户端库的当前版本这样说:


  

德precated。 (定于1.11至被删除)使用<一个href=\"http://javadoc.google-api-java-client.google$c$c.com/hg/1.10.3-beta/index.html?com/google/api/client/googleapis/auth/oauth2/GoogleCredential.html\"相对=nofollow> GoogleCredential


查看谷歌OAuth的wiki页面有关如何使用它的一个例子:

  GoogleCredential证书=新GoogleCredential()setAccessToken(的accessToken)。
再加上加= Plus.builder(新NetHttpTransport(),新JacksonFactory())
    .setApplicationName(谷歌-PlusSample / 1.0)
    .setHtt prequestInitializer(凭证)
    。建立();

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);
  ...
}

解决方案

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();

这篇关于日历API和OAuth的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆