I implemented Amazon SimpleDB in my mobile application and got it all working using the secret access key in a credentials file. From what I gather this won't work and isn't secure for mobile applications so I looked into using Cognito to verify the user and give them access to the SimpleDB.
I got Cognito connecting and syncing properly but for some reason when I pass the credentials to the new AmazonSimpleDBClient and then call a select expression it kicks out with a "Argument cannot be null" message.
This is how I'm calling it:
//Connect to the DB
var sdb = new AmazonSimpleDBClient(
credentials: Credentials,
region: RegionEndpoint.USWest2);
//Check if this user has any bots yet
string selectExpression = "Select count(*) From Bots where UserName = '" + username + "'";
var selectRequestAction = new SelectRequest { SelectExpression = selectExpression };
var selectResponse = sdb.Select(selectRequestAction);
And this is how Credentials are set up:
private CognitoAWSCredentials Credentials
{
get
{
if (_credentials == null)
_credentials = new CognitoAWSCredentials("IDENTITY_POOL_ID", RegionEndpoint.APSoutheast2);
return _credentials;
}
}
I can't seem to find anything relating to this issue or even anyone trying to use SimpleDB like this - they all seem to use hardcoded credentials whilst saying that it's insecure...
EDIT (Full Error) ArgumentNullException: Argument cannot be null. Parameter name: key System.Collections.Generic.Dictionary`2[System.Type,Amazon.Runtime.IExceptionHandler].TryGetValue (System.Type key, IExceptionHandler& value) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:588) Amazon.Runtime.Internal.ErrorHandler.ProcessException (IExecutionContext executionContext, System.Exception exception) (at E:/JenkinsWorkspaces/v3-stage-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/ErrorHandler/ErrorHandler.cs:202) Amazon.Runtime.Internal.ErrorHandler.InvokeSync (IExecutionContext executionContext) (at E:/JenkinsWorkspaces/v3-stage-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/ErrorHandler/ErrorHandler.cs:78) Amazon.Runtime.Internal.PipelineHandler.InvokeSync (IExecutionContext executionContext) (at E:/JenkinsWorkspaces/v3-stage-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/PipelineHandler.cs:57) Amazon.Runtime.Internal.CallbackHandler.InvokeSync (IExecutionContext executionContext) (at E:/JenkinsWorkspaces/v3-stage-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/Handlers/CallbackHandler.cs:45) Amazon.Runtime.Internal.PipelineHandler.InvokeSync (IExecutionContext executionContext) (at E:/JenkinsWorkspaces/v3-stage-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/PipelineHandler.cs:57) Amazon.Runtime.Internal.Signer.InvokeSync (IExecutionContext executionContext) (at E:/JenkinsWorkspaces/v3-stage-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/Handlers/Signer.cs:38) Amazon.Runtime.Internal.PipelineHandler.InvokeSync (IExecutionContext executionContext) (at E:/JenkinsWorkspaces/v3-stage-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/PipelineHandler.cs:57) Amazon.Runtime.Internal.CredentialsRetriever.InvokeSync (IExecutionContext executionContext) (at E:/JenkinsWorkspaces/v3-stage-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/Handlers/CredentialsRetriever.cs:72) Amazon.Runtime.Internal.PipelineHandler.InvokeSync (IExecutionContext executionContext) (at E:/JenkinsWorkspaces/v3-stage-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/PipelineHandler.cs:57) Amazon.Runtime.Internal.RetryHandler.InvokeSync (IExecutionContext executionContext) (at E:/JenkinsWorkspaces/v3-stage-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/RetryHandler/RetryHandler.cs:74)
Any help will be greatly appreciated.
Thanks
It turned out to be either a problem with my references or incompatible SimpleDB/Cognito packages.
I removed all references to Amazon. Updated NuGet and then used the NuGet command line to install Cognito and SimpleDB with these commands:
Install-Package AWSSDK.CognitoIdentity Install-Package AWSSDK.SimpleDB