Update dependencies
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
package de.jeyp91.googlecalendar;
|
||||
|
||||
import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
|
||||
import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport;
|
||||
import com.google.api.client.http.javanet.NetHttpTransport;
|
||||
import com.google.api.client.json.JsonFactory;
|
||||
import com.google.api.client.json.gson.GsonFactory;
|
||||
import com.google.api.services.calendar.CalendarScopes;
|
||||
import com.google.api.services.calendar.Calendar;
|
||||
import com.google.api.services.calendar.CalendarScopes;
|
||||
import com.google.auth.http.HttpCredentialsAdapter;
|
||||
import com.google.auth.oauth2.GoogleCredentials;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Collections;
|
||||
@@ -27,20 +28,23 @@ public class GoogleCalendarConnector {
|
||||
* @return An authorized Credential object.
|
||||
* @throws IOException If the Google_Credentials.json file cannot be found.
|
||||
*/
|
||||
private static GoogleCredential getCredentials() throws IOException {
|
||||
private static GoogleCredentials getGoogleCredentials() throws IOException {
|
||||
InputStream in = GoogleCalendarConnector.class.getResourceAsStream(SERVICE_CREDENTIALS_FILE_PATH);
|
||||
return GoogleCredential.fromStream(in)
|
||||
GoogleCredentials credentials = GoogleCredentials.fromStream(in)
|
||||
.createScoped(Collections.singleton(CalendarScopes.CALENDAR));
|
||||
credentials.refreshIfExpired();
|
||||
return credentials;
|
||||
}
|
||||
|
||||
public static com.google.api.services.calendar.Calendar getSerivce() {
|
||||
|
||||
com.google.api.services.calendar.Calendar service = null;
|
||||
Calendar service = null;
|
||||
|
||||
final NetHttpTransport HTTP_TRANSPORT;
|
||||
try {
|
||||
// Build a new authorized API client service.
|
||||
HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport();
|
||||
service = new Calendar.Builder(HTTP_TRANSPORT, JSON_FACTORY, getCredentials())
|
||||
service = new Calendar.Builder(HTTP_TRANSPORT, JSON_FACTORY, null)
|
||||
.setHttpRequestInitializer(new HttpCredentialsAdapter(getGoogleCredentials()))
|
||||
.setApplicationName(APPLICATION_NAME)
|
||||
.build();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user