Reputation: 639
We have done integration of AWS for Unauthenticated access but when we trying for Authenticated access then we getting error of InvalidParameterException: Please provide a valid public provider.
we using following steps for AWS integration into application:
DeveloperAuthenticationProvider developerProvider = new DeveloperAuthenticationProvider(
AppConstants.AWS_ACCOUNT_ID, AppConstants.IdentityPoolId, Regions.EU_WEST_1
);
CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider(
getActivity(),
developerProvider,
Regions.EU_WEST_1);
//set Logings for Authenticated Access
HashMap<String, String> loginsMap = new HashMap<String, String>();
loginsMap.put(developerProvider.getProviderName(), Token);
credentialsProvider.setLogins(loginsMap);
credentialsProvider.refresh();
We have done with DeveloperAuthenticationProvider class, which extends AWSAbstractCognitoDeveloperIdentityProvider; where we provide developer provider name(developerProvider.getProviderName()) and Token is as a OpenID token.
But I getting below errors:
Caused by: com.amazonaws.services.cognitoidentity.model.InvalidParameterException: Please provide a valid public provider
and sometimes I getting errors of: Identity ID is forbidden. I couldn't understand causes of these errors. I referred following URLs: https://docs.aws.amazon.com/cognito/devguide/identity/developer-authenticated-identities/, https://mobile.awsblog.com/post/Tx3E3NJURV1LNV1/Integrating-Amazon-Cognito-using-developer-authenticated-identities-An-end-to-en.
Please suggest me how can I solve out these errors and give some updated references where I can understand causes of these errors.
Upvotes: 2
Views: 2081
Reputation: 639
Hurreyyy, I resolved issue of Developer Authentication for AWS Cognito Service. Its easy to understand but quite hard to implement.
Here is solution :
CognitoSyncClientManager.init(this, cognitoParams);
CognitoSyncClientManager.credentialsProvider.clearCredentials();
CognitoSyncClientManager.addLogins(AppConstants.DEVELOPER_PROVIDER, strToken);
and you can get CognitoSyncClientManager from CognitoSyncDemo.
Thanks to all
Upvotes: 1
Reputation: 9020
It looks like you are setting the token in the logins map, instead of the token field of your developer provider as noted in the developer guide. You may also want to refer to our end-to-end example available on GitHub which includes example code for both iOS and Android.
Upvotes: 2
Reputation: 9335
Make sure that the value you're returning from developerProvider.getProviderName()
is the same value that you have registered in the Amazon Cognito console as described in the steps under the Associate Developer Provider section of the Developer Authenticated Identities topic in the Amazon Cognito Developer Guide.
Upvotes: 0