I’m trying to understand Google services and OAuth 2.0 while working on a Calendar app.
I encountered this issue and am not able to find a solution. Please let me know any way through this. In the code below, I get the warning that calendar.builder is deprecated.
What is another alternative?
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();
For
Calendar.Builderthe constructor has changed a bit:So your code would be: