use of com.amplifyframework.api.ApiCategory in project amplify-android by aws-amplify.
the class TestApiCategory method fromConfiguration.
/**
* Creates an instance of {@link ApiCategory}, using the provided configuration
* file, referred to by its android resource ID.
* @return A configured and initialized ApiCategory instance
*/
@NonNull
static ApiCategory fromConfiguration(@RawRes int resourceId) throws AmplifyException {
CognitoUserPoolsAuthProvider cognitoUserPoolsAuthProvider = new DefaultCognitoUserPoolsAuthProvider(AWSMobileClient.getInstance());
ApiAuthProviders providers = ApiAuthProviders.builder().awsCredentialsProvider(AWSMobileClient.getInstance()).cognitoUserPoolsAuthProvider(cognitoUserPoolsAuthProvider).build();
AWSApiPlugin plugin = AWSApiPlugin.builder().apiAuthProviders(providers).build();
ApiCategory apiCategory = new ApiCategory();
apiCategory.addPlugin(plugin);
CategoryConfiguration apiConfiguration = AmplifyConfiguration.fromConfigFile(getApplicationContext(), resourceId).forCategoryType(CategoryType.API);
apiCategory.configure(apiConfiguration, getApplicationContext());
// apiCategory.initialize(...); Doesn't currently contain any logic, so, skip it.
return apiCategory;
}
Aggregations