use of com.amazonaws.mobile.config.AWSConfiguration in project aws-mobile-appsync-sdk-android by awslabs.
the class AWSAppSyncClients method withIAMFromAWSConfiguration.
@NonNull
public static AWSAppSyncClient withIAMFromAWSConfiguration(boolean subscriptionsAutoReconnect, long credentialsDelay) {
AWSConfiguration awsConfiguration = new AWSConfiguration(getTargetContext());
awsConfiguration.setConfiguration("MultiAuthAndroidIntegTestApp_AWS_IAM");
JSONObject ccpConfig = awsConfiguration.optJsonObject("CredentialsProvider");
String cognitoIdentityPoolID = JsonExtract.stringValue(ccpConfig, "CognitoIdentity.Default.PoolId");
String cognitoRegion = JsonExtract.stringValue(ccpConfig, "CognitoIdentity.Default.Region");
DelayedCognitoCredentialsProvider credentialsProvider = new DelayedCognitoCredentialsProvider(cognitoIdentityPoolID, Regions.fromName(cognitoRegion), credentialsDelay);
AmazonS3Client s3Client = new AmazonS3Client(credentialsProvider, Region.getRegion("us-west-2"));
S3ObjectManager s3ObjectManager = new S3ObjectManagerImplementation(s3Client);
return AWSAppSyncClient.builder().context(getTargetContext()).credentialsProvider(credentialsProvider).awsConfiguration(awsConfiguration).conflictResolver(new TestConflictResolver()).s3ObjectManager(s3ObjectManager).subscriptionsAutoReconnect(subscriptionsAutoReconnect).mutationQueueExecutionTimeout(TimeUnit.SECONDS.toMillis(30)).persistentMutationsCallback(LoggingPersistentMutationsCallback.instance()).useClientDatabasePrefix(true).build();
}
use of com.amazonaws.mobile.config.AWSConfiguration in project aws-mobile-appsync-sdk-android by awslabs.
the class AWSAppSyncClients method withUserPoolsFromAWSConfiguration.
@NonNull
public static AWSAppSyncClient withUserPoolsFromAWSConfiguration(ResponseFetcher responseFetcher) {
// Amazon Cognito User Pools
AWSConfiguration awsConfiguration = new AWSConfiguration(getTargetContext());
awsConfiguration.setConfiguration("MultiAuthAndroidIntegTestApp_AMAZON_COGNITO_USER_POOLS");
return AWSAppSyncClient.builder().context(getTargetContext()).awsConfiguration(awsConfiguration).cognitoUserPoolsAuthProvider(() -> {
try {
String idToken = TestAWSMobileClient.instance(getTargetContext()).getTokens().getIdToken().getTokenString();
Log.d(TAG, "idToken = " + idToken);
return idToken;
} catch (Exception exception) {
exception.printStackTrace();
return null;
}
}).useClientDatabasePrefix(true).defaultResponseFetcher(responseFetcher).build();
}
use of com.amazonaws.mobile.config.AWSConfiguration in project aws-mobile-appsync-sdk-android by awslabs.
the class AWSAppSyncClients method withUserPools2FromAWSConfiguration.
@NonNull
public static AWSAppSyncClient withUserPools2FromAWSConfiguration(String idTokenStringForCustomCognitoUserPool, ResponseFetcher responseFetcher) {
// Amazon Cognito User Pools - Custom CognitoUserPool
String clientDatabasePrefix = null;
String clientName = null;
AWSConfiguration awsConfiguration = new AWSConfiguration(getTargetContext());
awsConfiguration.setConfiguration("MultiAuthAndroidIntegTestApp_AMAZON_COGNITO_USER_POOLS_2");
try {
clientDatabasePrefix = awsConfiguration.optJsonObject("AppSync").getString("ClientDatabasePrefix");
clientName = awsConfiguration.optJsonObject("AppSync").getString("AuthMode");
} catch (JSONException e) {
e.printStackTrace();
}
AWSAppSyncClient.Builder awsAppSyncClientBuilder4 = AWSAppSyncClient.builder().context(getTargetContext()).cognitoUserPoolsAuthProvider(() -> idTokenStringForCustomCognitoUserPool).awsConfiguration(awsConfiguration).useClientDatabasePrefix(true).defaultResponseFetcher(responseFetcher);
AWSAppSyncClient awsAppSyncClient4 = awsAppSyncClientBuilder4.build();
validateAppSyncClient(awsAppSyncClient4, clientDatabasePrefix, clientName);
return awsAppSyncClient4;
}
Aggregations