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) {
// Amazon Cognito User Pools - Custom CognitoUserPool
AWSConfiguration awsConfiguration = new AWSConfiguration(getTargetContext());
awsConfiguration.setConfiguration("MultiAuthAndroidIntegTestApp_AMAZON_COGNITO_USER_POOLS_2");
JSONObject appSyncConfig = awsConfiguration.optJsonObject("AppSync");
String clientDatabasePrefix = JsonExtract.stringValue(appSyncConfig, "ClientDatabasePrefix");
String clientName = JsonExtract.stringValue(appSyncConfig, "AuthMode");
AWSAppSyncClient.Builder awsAppSyncClientBuilder4 = AWSAppSyncClient.builder().context(getTargetContext()).cognitoUserPoolsAuthProvider(() -> idTokenStringForCustomCognitoUserPool).awsConfiguration(awsConfiguration).useClientDatabasePrefix(true);
AWSAppSyncClient awsAppSyncClient4 = awsAppSyncClientBuilder4.build();
validateAppSyncClient(awsAppSyncClient4, clientDatabasePrefix, clientName);
return awsAppSyncClient4;
}
use of com.amazonaws.mobile.config.AWSConfiguration in project amplify-android by aws-amplify.
the class AnalyticsPinpointInstrumentedTest method setUp.
/**
* Configure the Amplify framework.
*
* @throws AmplifyException From Amplify configuration.
*/
@BeforeClass
public static void setUp() throws AmplifyException {
final CountDownLatch latch = new CountDownLatch(1);
final AtomicReference<Exception> asyncException = new AtomicReference<>();
Context context = getApplicationContext();
AWSMobileClient.getInstance().initialize(context, new AWSConfiguration(context), new Callback<UserStateDetails>() {
@Override
public void onResult(UserStateDetails result) {
latch.countDown();
}
@Override
public void onError(Exception exception) {
asyncException.set(exception);
latch.countDown();
}
});
try {
if (latch.await(AUTH_TIMEOUT, TimeUnit.SECONDS)) {
if (asyncException.get() != null) {
fail("Failed to instantiate AWSMobileClient");
}
} else {
fail("Failed to instantiate AWSMobileClient within " + AUTH_TIMEOUT + " seconds");
}
} catch (InterruptedException error) {
fail("Failed to instantiate AWSMobileClient");
}
AWSPinpointAnalyticsPlugin plugin = new AWSPinpointAnalyticsPlugin((Application) context, AWSMobileClient.getInstance());
Amplify.addPlugin(plugin);
Amplify.configure(context);
analyticsClient = plugin.getAnalyticsClient();
targetingClient = plugin.getTargetingClient();
}
use of com.amazonaws.mobile.config.AWSConfiguration in project aws-sdk-android by aws-amplify.
the class AWSMobileClientTest method testAWSConfigurationForCognitoUserPool.
@Test
public void testAWSConfigurationForCognitoUserPool() throws Exception {
// Context of the app under test.
Context appContext = ApplicationProvider.getApplicationContext();
final AWSConfiguration awsConfiguration = new AWSConfiguration(appContext);
assertNotNull(awsConfiguration.optJsonObject("CognitoUserPool"));
assertEquals("us-west-2", awsConfiguration.optJsonObject("CognitoUserPool").getString("Region"));
assertEquals("com.amazonaws.mobile.client.test", appContext.getPackageName());
}
use of com.amazonaws.mobile.config.AWSConfiguration in project aws-sdk-android by aws-amplify.
the class OAuth2Utils method initialize.
@AnyThread
public void initialize(final Context context, final Callback<UserStateDetails> callback) {
final Context applicationContext = context.getApplicationContext();
initialize(applicationContext, new AWSConfiguration(applicationContext), callback);
}
use of com.amazonaws.mobile.config.AWSConfiguration in project aws-sdk-android by aws-amplify.
the class AWSMobileClientCustomAuthTest method beforeClass.
@BeforeClass
public static void beforeClass() throws Exception {
appContext = ApplicationProvider.getApplicationContext();
final CountDownLatch latch = new CountDownLatch(1);
final AWSConfiguration awsConfiguration = new AWSConfiguration(appContext);
awsConfiguration.setConfiguration("Auth1");
assert awsConfiguration.optJsonObject("Auth").has("authenticationFlowType");
AWSMobileClient.getInstance().initialize(appContext, awsConfiguration, new Callback<UserStateDetails>() {
@Override
public void onResult(UserStateDetails result) {
latch.countDown();
}
@Override
public void onError(Exception e) {
Log.e(TAG, "onError: ", e);
latch.countDown();
}
});
latch.await();
auth = AWSMobileClient.getInstance();
}
Aggregations