Search in sources :

Example 1 with CustomLocalServerReceiver

use of org.pentaho.googledrive.vfs.util.CustomLocalServerReceiver in project pentaho-kettle by pentaho.

the class GoogleDriveFileObject method authorize.

private Credential authorize() throws IOException {
    InputStream in = new FileInputStream(resolveCredentialsPath() + "/" + resourceBundle.getString("client.secrets"));
    GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(in));
    GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, SCOPES).setDataStoreFactory(DATA_STORE_FACTORY).setAccessType("offline").build();
    Credential credential = new CustomAuthorizationCodeInstalledApp(flow, new CustomLocalServerReceiver()).authorize("user");
    return credential;
}
Also used : Credential(com.google.api.client.auth.oauth2.Credential) CustomAuthorizationCodeInstalledApp(org.pentaho.googledrive.vfs.util.CustomAuthorizationCodeInstalledApp) CustomLocalServerReceiver(org.pentaho.googledrive.vfs.util.CustomLocalServerReceiver) GoogleAuthorizationCodeFlow(com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow) GoogleClientSecrets(com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets)

Aggregations

Credential (com.google.api.client.auth.oauth2.Credential)1 GoogleAuthorizationCodeFlow (com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow)1 GoogleClientSecrets (com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets)1 CustomAuthorizationCodeInstalledApp (org.pentaho.googledrive.vfs.util.CustomAuthorizationCodeInstalledApp)1 CustomLocalServerReceiver (org.pentaho.googledrive.vfs.util.CustomLocalServerReceiver)1