我正在尝试在使用日历应用程序时了解 Google 服务和 OAuth 2.0。我遇到了这个问题,无法找到解决方案。请让我知道任何方式。calendar.builder
在下面的代码中,我收到了已弃用的警告。另一种选择是什么?
public static Calendar build(GoogleCredential credentials) {
HttpTransport transport = AndroidHttp.newCompatibleTransport();
JacksonFactory jsonFactory = new JacksonFactory();
com.google.api.services.calendar.Calendar service;
service = Calendar.builder(transport, jsonFactory)
.setApplicationName("Meetrbus/1.0")
.setJsonHttpRequestInitializer(new JsonHttpRequestInitializer() {
@Override
public void initialize(JsonHttpRequest request) {
CalendarRequest calendarRequest = (CalendarRequest) request;
//TODO: Get an API key from Google's APIs Console:
// https://code.google.com/apis/console.
calendarRequest.setKey(<My Key>);
}
}).setHttpRequestInitializer(credentials).build();