Search in sources :

Example 1 with AppCredentials

use of org.dataportabilityproject.types.transfer.auth.AppCredentials in project data-transfer-project by google.

the class MicrosoftAuthServiceExtension method initialize.

@Override
public void initialize(ExtensionContext context) {
    mapper = context.getTypeManager().getMapper();
    OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder();
    okHttpClient = clientBuilder.build();
    AppCredentialStore appCredentialStore = context.getService(AppCredentialStore.class);
    try {
        AppCredentials credentials = appCredentialStore.getAppCredentials("MICROSOFT_KEY", "MICROSOFT_SECRET");
        if (credentials == null) {
            throw new IllegalStateException("Microsoft Graph API credentials not found");
        }
    } catch (IOException e) {
        throw new IllegalStateException("Error retrieving Microsoft Graph API credentials - Were they set?", e);
    }
    importAuthDataGenerators = new HashMap<>();
    exportAuthDataGenerators = new HashMap<>();
    initialized = true;
}
Also used : OkHttpClient(okhttp3.OkHttpClient) AppCredentialStore(org.dataportabilityproject.spi.cloud.storage.AppCredentialStore) AppCredentials(org.dataportabilityproject.types.transfer.auth.AppCredentials) IOException(java.io.IOException)

Example 2 with AppCredentials

use of org.dataportabilityproject.types.transfer.auth.AppCredentials in project data-transfer-project by google.

the class GoogleAppCredentialStore method getAppCredentials.

public AppCredentials getAppCredentials(String keyName, String secretName) throws IOException {
    String key;
    String secret;
    try {
        key = keys.get(keyName);
    } catch (ExecutionException e) {
        throw new IOException("Couldn't lookup key: " + keyName, e);
    }
    try {
        secret = secrets.get(secretName);
    } catch (ExecutionException e) {
        throw new IOException("Couldn't lookup secret: " + secretName, e);
    }
    return new AppCredentials(key, secret);
}
Also used : AppCredentials(org.dataportabilityproject.types.transfer.auth.AppCredentials) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

IOException (java.io.IOException)2 AppCredentials (org.dataportabilityproject.types.transfer.auth.AppCredentials)2 ExecutionException (java.util.concurrent.ExecutionException)1 OkHttpClient (okhttp3.OkHttpClient)1 AppCredentialStore (org.dataportabilityproject.spi.cloud.storage.AppCredentialStore)1