我可以使用 AWS Cognito 凭证访问 Amazon SimpleDB 吗?

Can I use AWS Cognito Credentials to access Amazon SimpleDB?

我在我的移动应用程序中实施了 Amazon SimpleDB,并使用凭证文件中的秘密访问密钥使其全部正常工作。据我所知,这对移动应用程序来说行不通并且不安全,因此我研究了使用 Cognito 来验证用户并授予他们访问 SimpleDB 的权限。

我已正确连接和同步 Cognito,但出于某种原因,当我将凭据传递给新的 AmazonSimpleDBClient 然后调用 select 表达式时,它会弹出 "Argument cannot be null" 消息。

我是这样称呼它的:

        //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);

这就是凭据的设置方式:

private CognitoAWSCredentials Credentials
{
    get
    {
        if (_credentials == null)
            _credentials = new CognitoAWSCredentials("IDENTITY_POOL_ID", RegionEndpoint.APSoutheast2);
        return _credentials;
    }
}

我似乎找不到与此问题相关的任何内容,甚至找不到任何人试图像这样使用 SimpleDB - 他们似乎都使用硬编码凭据,同时说它不安全...

编辑(完全错误) ArgumentNullException:参数不能为空。 参数名称:键 System.Collections.Generic.Dictionary`2[System.Type,Amazon.Runtime.IExceptionHandler].TryGetValue(System.Type 键,IExceptionHandler& 值)(在 /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs :588) Amazon.Runtime.Internal.ErrorHandler.ProcessException (IExecutionContext executionContext, System.Exception 异常) (在 E:/JenkinsWorkspaces/v3-stage-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/ErrorHandler/ErrorHandler.cs:202) Amazon.Runtime.Internal.ErrorHandler.InvokeSync (IExecutionContext executionContext) (在 E:/JenkinsWorkspaces/v3-stage-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/ErrorHandler/ErrorHandler.cs:78) Amazon.Runtime.Internal.PipelineHandler.InvokeSync (IExecutionContext 执行上下文) (在 E:/JenkinsWorkspaces/v3-stage-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/PipelineHandler.cs:57) Amazon.Runtime.Internal.CallbackHandler.InvokeSync (IExecutionContext 执行上下文) (在 E:/JenkinsWorkspaces/v3-stage-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/Handlers/CallbackHandler.cs:45) Amazon.Runtime.Internal.PipelineHandler.InvokeSync (IExecutionContext 执行上下文) (在 E:/JenkinsWorkspaces/v3-stage-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/PipelineHandler.cs:57) Amazon.Runtime.Internal.Signer.InvokeSync (IExecutionContext 执行上下文) (在 E:/JenkinsWorkspaces/v3-stage-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/Handlers/Signer.cs:38) Amazon.Runtime.Internal.PipelineHandler.InvokeSync (IExecutionContext 执行上下文) (在 E:/JenkinsWorkspaces/v3-stage-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/PipelineHandler.cs:57) Amazon.Runtime.Internal.CredentialsRetriever.InvokeSync (IExecutionContext executionContext) (在 E:/JenkinsWorkspaces/v3-stage-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/Handlers/CredentialsRetriever.cs:72) Amazon.Runtime.Internal.PipelineHandler.InvokeSync (IExecutionContext 执行上下文) (在 E:/JenkinsWorkspaces/v3-stage-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/PipelineHandler.cs:57) Amazon.Runtime.Internal.RetryHandler.InvokeSync (IExecutionContext executionContext) (在 E:/JenkinsWorkspaces/v3-stage-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/RetryHandler/RetryHandler.cs:74)

任何帮助将不胜感激。

谢谢

事实证明要么是我的引用有问题,要么是 SimpleDB/Cognito 软件包不兼容。

我删除了所有对亚马逊的引用。更新了 NuGet,然后使用 NuGet 命令行通过以下命令安装 Cognito 和 SimpleDB:

Install-Package AWSSDK.CognitoIdentity Install-PackageAWSSDK.SimpleDB