C#Unity中的AWS Cognito用户身份验证

时间:2018-04-02 15:23:05

标签: c# unity3d aws-sdk amazon-cognito aws-cognito

我一直在努力让AWS Cognito用户授权在Unity 2017中运行。

根据此请求,Unity SDK存在限制: https://forums.aws.amazon.com/thread.jspa?threadID=248872

我尝试了几种不同的方法,而我最接近的是这里的代码: https://gist.github.com/dbeattie71/44ea3a13145f185d303e620c299ab1c5

然而,当我调用LoginUser并设置了所有细节时,我得到了这个堆栈:

ArgumentNullException: Value cannot be null.
Parameter name: key
System.ThrowHelper.ThrowArgumentNullException (System.ExceptionArgument argument) (at <c95265f74fdf4905bfb0d5a4b652216c>:0)
System.Collections.Generic.Dictionary`2[TKey,TValue].FindEntry (TKey key) (at <c95265f74fdf4905bfb0d5a4b652216c>:0)
System.Collections.Generic.Dictionary`2[TKey,TValue].TryGetValue (TKey key, TValue& value) (at <c95265f74fdf4905bfb0d5a4b652216c>:0)
Amazon.Runtime.Internal.ErrorHandler.ProcessException (Amazon.Runtime.IExecutionContext executionContext, System.Exception exception) (at E:/JenkinsWorkspaces/v3-trebuchet-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/ErrorHandler/ErrorHandler.cs:202)
Amazon.Runtime.Internal.ErrorHandler.InvokeSync (Amazon.Runtime.IExecutionContext executionContext) (at E:/JenkinsWorkspaces/v3-trebuchet-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/ErrorHandler/ErrorHandler.cs:78)
Amazon.Runtime.Internal.PipelineHandler.InvokeSync (Amazon.Runtime.IExecutionContext executionContext) (at E:/JenkinsWorkspaces/v3-trebuchet-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/PipelineHandler.cs:57)
Amazon.Runtime.Internal.CallbackHandler.InvokeSync (Amazon.Runtime.IExecutionContext executionContext) (at E:/JenkinsWorkspaces/v3-trebuchet-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/Handlers/CallbackHandler.cs:45)
Amazon.Runtime.Internal.PipelineHandler.InvokeSync (Amazon.Runtime.IExecutionContext executionContext) (at E:/JenkinsWorkspaces/v3-trebuchet-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/PipelineHandler.cs:57)
Amazon.Runtime.Internal.Signer.InvokeSync (Amazon.Runtime.IExecutionContext executionContext) (at E:/JenkinsWorkspaces/v3-trebuchet-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/Handlers/Signer.cs:38)
Amazon.Runtime.Internal.PipelineHandler.InvokeSync (Amazon.Runtime.IExecutionContext executionContext) (at E:/JenkinsWorkspaces/v3-trebuchet-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/PipelineHandler.cs:57)
Amazon.Runtime.Internal.CredentialsRetriever.InvokeSync (Amazon.Runtime.IExecutionContext executionContext) (at E:/JenkinsWorkspaces/v3-trebuchet-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/Handlers/CredentialsRetriever.cs:72)
Amazon.Runtime.Internal.PipelineHandler.InvokeSync (Amazon.Runtime.IExecutionContext executionContext) (at E:/JenkinsWorkspaces/v3-trebuchet-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/PipelineHandler.cs:57)
Amazon.Runtime.Internal.RetryHandler.InvokeSync (Amazon.Runtime.IExecutionContext executionContext) (at E:/JenkinsWorkspaces/v3-trebuchet-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/RetryHandler/RetryHandler.cs:84)
Amazon.Runtime.Internal.PipelineHandler.InvokeSync (Amazon.Runtime.IExecutionContext executionContext) (at E:/JenkinsWorkspaces/v3-trebuchet-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/PipelineHandler.cs:57)
Amazon.Runtime.Internal.CallbackHandler.InvokeSync (Amazon.Runtime.IExecutionContext executionContext) (at E:/JenkinsWorkspaces/v3-trebuchet-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/Handlers/CallbackHandler.cs:45)
Amazon.Runtime.Internal.PipelineHandler.InvokeSync (Amazon.Runtime.IExecutionContext executionContext) (at E:/JenkinsWorkspaces/v3-trebuchet-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/PipelineHandler.cs:57)
Amazon.Runtime.Internal.EndpointResolver.InvokeSync (Amazon.Runtime.IExecutionContext executionContext) (at E:/JenkinsWorkspaces/v3-trebuchet-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/Handlers/EndpointResolver.cs:34)
Amazon.Runtime.Internal.PipelineHandler.InvokeSync (Amazon.Runtime.IExecutionContext executionContext) (at E:/JenkinsWorkspaces/v3-trebuchet-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/PipelineHandler.cs:57)
Amazon.Runtime.Internal.Marshaller.InvokeSync (Amazon.Runtime.IExecutionContext executionContext) (at E:/JenkinsWorkspaces/v3-trebuchet-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/Handlers/Marshaller.cs:37)
Amazon.Runtime.Internal.PipelineHandler.InvokeSync (Amazon.Runtime.IExecutionContext executionContext) (at E:/JenkinsWorkspaces/v3-trebuchet-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/PipelineHandler.cs:57)
Amazon.Runtime.Internal.CallbackHandler.InvokeSync (Amazon.Runtime.IExecutionContext executionContext) (at E:/JenkinsWorkspaces/v3-trebuchet-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/Handlers/CallbackHandler.cs:45)
Amazon.Runtime.Internal.PipelineHandler.InvokeSync (Amazon.Runtime.IExecutionContext executionContext) (at E:/JenkinsWorkspaces/v3-trebuchet-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/PipelineHandler.cs:57)
Amazon.Runtime.Internal.ErrorCallbackHandler.InvokeSync (Amazon.Runtime.IExecutionContext executionContext) (at E:/JenkinsWorkspaces/v3-trebuchet-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/Handlers/ErrorCallbackHandler.cs:44)
Amazon.Runtime.Internal.PipelineHandler.InvokeSync (Amazon.Runtime.IExecutionContext executionContext) (at E:/JenkinsWorkspaces/v3-trebuchet-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/PipelineHandler.cs:57)
Amazon.Runtime.Internal.MetricsHandler.InvokeSync (Amazon.Runtime.IExecutionContext executionContext) (at E:/JenkinsWorkspaces/v3-trebuchet-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/Handlers/MetricsHandler.cs:40)
Amazon.Runtime.Internal.PipelineHandler.InvokeSync (Amazon.Runtime.IExecutionContext executionContext) (at E:/JenkinsWorkspaces/v3-trebuchet-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/PipelineHandler.cs:57)
Amazon.Runtime.Internal.RuntimePipeline.InvokeSync (Amazon.Runtime.IExecutionContext executionContext) (at E:/JenkinsWorkspaces/v3-trebuchet-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/RuntimePipeline.cs:135)
Amazon.Runtime.AmazonServiceClient.Invoke[TRequest,TResponse] (TRequest request, Amazon.Runtime.Internal.Transform.IMarshaller`2[T,R] marshaller, Amazon.Runtime.Internal.Transform.ResponseUnmarshaller unmarshaller) (at E:/JenkinsWorkspaces/v3-trebuchet-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/AmazonServiceClient.cs:204)
Amazon.CognitoIdentityProvider.AmazonCognitoIdentityProviderClient.InitiateAuth (Amazon.CognitoIdentityProvider.Model.InitiateAuthRequest request) (at <d5265c16c8474ca8b01b52f514c6ef90>:0)
Com.Mmlac.Authentication.LoginUser (System.String username, System.String password) (at Assets/Authentication.cs:40)
AuthenticationTest.Start () (at Assets/AuthenticationTest.cs:20)

预先要求:

1 个答案:

答案 0 :(得分:0)

我认为您可能会发现AWSSDK.Extensions.CognitoAuthentication很有用,它会增强AWS SDK for .NET,这在AWS Cognito和身份验证领域非常有限。特别是该库处理SRP协议,这是开发人员在我在GitHub上看到的一些项目中编写自己的东西。

在亚马逊博客文章here

中对此库进行了很好的介绍