C# AWS Cognito注册
我正试图遵循使用C#from在Cognito中注册用户的示例。我不得不添加一些东西,因为C# AWS Cognito注册,c#,amazon-cognito,C#,Amazon Cognito,我正试图遵循使用C#from在Cognito中注册用户的示例。我不得不添加一些东西,因为AmazonCongnitoIdentityProviderClient没有空构造函数。我的应用程序恰好是Xamarin表单应用程序,但这不重要。我试着在一个.NETStandard项目中这样做,但是不断地得到一个错误,说这个方法不存在。所以我切换到PCL,现在我得到System.IO.InvalidDataException:无法确定协议。我在Android和iOS上都遇到了这个错误 这是我的密码: pub
AmazonCongnitoIdentityProviderClient
没有空构造函数。我的应用程序恰好是Xamarin表单应用程序,但这不重要。我试着在一个.NETStandard项目中这样做,但是不断地得到一个错误,说这个方法不存在。所以我切换到PCL,现在我得到System.IO.InvalidDataException:无法确定协议
。我在Android和iOS上都遇到了这个错误
这是我的密码:
public async Task SignupUser(string username, string password, string email)
{
const string UserPoolId = "us-east-1_XXXXXXXXX";
const string ClientId = "6xxxxxxxxxxxxxxxxxxxxxxxxx";
const string ClientSecret = "my-client-secret";
const string CognitoIdentityPoolId = "us-east-1:identity-pool-id-here";
try
{
AmazonCognitoIdentityProviderConfig providerConfig = new AmazonCognitoIdentityProviderConfig()
{
RegionEndpoint = RegionEndpoint.USEast1
};
CognitoAWSCredentials cogCreds = new CognitoAWSCredentials(CognitoIdentityPoolId, RegionEndpoint.USEast1);
IdentityProvider = new AmazonCognitoIdentityProviderClient(cogCreds, RegionEndpoint.USEast1);
SignUpRequest signUpRequest = new SignUpRequest()
{
ClientId = ClientId,
Password = password,
Username = username
};
AttributeType emailAttribute = new AttributeType()
{
Name = "email",
Value = email
};
signUpRequest.UserAttributes.Add(emailAttribute);
var signUpResult = await IdentityProvider.SignUpAsync(signUpRequest);
}
catch (Exception ex)
{
Debug.WriteLine(ex);
}
}
例外情况如下:
System.IO.InvalidDataException: Cannot determine protocol
at Amazon.Runtime.Internal.Signer.SignRequest (Amazon.Runtime.IRequestContext requestContext) [0x0007a] in <e08989525980425e9b2f389f7417830e>:0
at Amazon.Runtime.Internal.Signer.PreInvoke (Amazon.Runtime.IExecutionContext executionContext) [0x00013] in <e08989525980425e9b2f389f7417830e>:0
at Amazon.Runtime.Internal.Signer.InvokeAsync[T] (Amazon.Runtime.IExecutionContext executionContext) [0x00000] in <e08989525980425e9b2f389f7417830e>:0
at Amazon.Runtime.Internal.PipelineHandler.InvokeAsync[T] (Amazon.Runtime.IExecutionContext executionContext) [0x0000e] in <e08989525980425e9b2f389f7417830e>:0
at Amazon.Runtime.Internal.CredentialsRetriever.<>n__0[T] (Amazon.Runtime.IExecutionContext executionContext) [0x00000] in <e08989525980425e9b2f389f7417830e>:0
at Amazon.Runtime.Internal.CredentialsRetriever+<InvokeAsync>d__7`1[T].MoveNext () [0x00103] in <e08989525980425e9b2f389f7417830e>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:152
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00037] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:535
at Amazon.Runtime.Internal.RetryHandler+<InvokeAsync>d__10`1[T].MoveNext () [0x000b0] in <e08989525980425e9b2f389f7417830e>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:152
at Amazon.Runtime.Internal.RetryHandler+<InvokeAsync>d__10`1[T].MoveNext () [0x001b0] in <e08989525980425e9b2f389f7417830e>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:152
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00037] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:535
at Amazon.Runtime.Internal.CallbackHandler+<InvokeAsync>d__9`1[T].MoveNext () [0x00080] in <e08989525980425e9b2f389f7417830e>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:152
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00037] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:535
at Amazon.Runtime.Internal.CallbackHandler+<InvokeAsync>d__9`1[T].MoveNext () [0x00080] in <e08989525980425e9b2f389f7417830e>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:152
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00037] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:535
at Amazon.Runtime.Internal.ErrorCallbackHandler+<InvokeAsync>d__5`1[T].MoveNext () [0x00099] in <e08989525980425e9b2f389f7417830e>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:152
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00037] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:535
at Amazon.Runtime.Internal.MetricsHandler+<InvokeAsync>d__1`1[T].MoveNext () [0x000ab] in <e08989525980425e9b2f389f7417830e>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:152
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00037] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128
at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:357
System.IO.InvalidDataException:无法确定协议
在:0中的Amazon.Runtime.Internal.Signer.SignRequest(Amazon.Runtime.IRequestContext requestContext)[0x0007a]处
在:0中的Amazon.Runtime.Internal.Signer.PreInvoke(Amazon.Runtime.IExecutionContext executionContext)[0x00013]处
在:0中的Amazon.Runtime.Internal.Signer.InvokeAsync[T](Amazon.Runtime.IExecutionContext executionContext)[0x00000]处
在:0中的Amazon.Runtime.Internal.PipelineHandler.InvokeAsync[T](Amazon.Runtime.IExecutionContext executionContext)[0x0000e]处
在Amazon.Runtime.Internal.CredentialsRetriever.n_u0[T](Amazon.Runtime.IExecutionContext executionContext)[0x00000]中:0
在Amazon.Runtime.Internal.CredentialsRetriever+d_u7`1[T].MoveNext()[0x00103]中:0
---来自引发异常的上一个位置的堆栈结束跟踪---
在/Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/System/Runtime/ExceptionServices/ExceptionServices/exceptionservicescommon.cs:152中的System.Runtime.ExceptionDispatchInfo.thInfo()[0x0000c]
在/Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/System/Runtime/CompilerServices/TaskAwaiter.cs:187中的System.Runtime.CompilerServices.taskwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task任务)[0x00037]
在/Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/System/Runtime/CompilerServices/TaskAwaiter.cs:156中的System.Runtime.CompilerServices.taskwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task任务)[0x00028]处
在/Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/System/Runtime/CompilerServices/TaskAwaiter.cs:128中的System.Runtime.CompilerServices.taskwaiter.ValidateEnd(System.Threading.Tasks.Task任务)[0x00008]
在/Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/System/Runtime/CompilerServices/TaskAwaiter.cs:535中的System.Runtime.CompilerServices.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult()[0x00000]
在Amazon.Runtime.Internal.RetryHandler+d_u10`1[T].MoveNext()[0x000b0]中:0
---来自引发异常的上一个位置的堆栈结束跟踪---
在/Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/System/Runtime/ExceptionServices/ExceptionServices/exceptionservicescommon.cs:152中的System.Runtime.ExceptionDispatchInfo.thInfo()[0x0000c]
在Amazon.Runtime.Internal.RetryHandler+d_u10`1[T].MoveNext()[0x001b0]中:0
---来自引发异常的上一个位置的堆栈结束跟踪---
在/Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/System/Runtime/ExceptionServices/ExceptionServices/exceptionservicescommon.cs:152中的System.Runtime.ExceptionDispatchInfo.thInfo()[0x0000c]
在/Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/System/Runtime/CompilerServices/TaskAwaiter.cs:187中的System.Runtime.CompilerServices.taskwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task任务)[0x00037]
在/Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/System/Runtime/CompilerServices/TaskAwaiter.cs:156中的System.Runtime.CompilerServices.taskwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task任务)[0x00028]处
在/Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/System/Runtime/CompilerServices/TaskAwaiter.cs:128中的System.Runtime.CompilerServices.taskwaiter.ValidateEnd(System.Threading.Tasks.Task任务)[0x00008]
在/Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/System/Runtime/CompilerServices/TaskAwaiter.cs:535中的System.Runtime.CompilerServices.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult()[0x00000]
在Amazon.Runtime.Internal.CallbackHandler+d_u9`1[T].MoveNext()[0x00080]中:0
---来自引发异常的上一个位置的堆栈结束跟踪---
在/Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/System/Runtime/ExceptionServices/ExceptionServices/exceptionservicescommon.cs:152中的System.Runtime.ExceptionDispatchInfo.thInfo()[0x0000c]
在/Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/System/Runtime/CompilerServices/TaskAwaiter.cs:187中的System.Runtime.CompilerServices.taskwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task任务)[0x00037]
在/Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/System/Runtime/CompilerServices/TaskAwaiter.cs:156中的System.Runtime.CompilerServices.taskwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task任务)[0x00028]处
在/Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.4/src/mono/mcs/class/referencesource/mscorlib/System/Runtime/CompilerServices/TaskAwaiter.cs:128中的System.Runtime.CompilerServices.taskwaiter.ValidateEnd(System.Threading.Tasks.Task任务)[0x00008]
在System.Runtime.Compilers上
IdentityProvider = new AmazonCognitoIdentityProviderClient(null, RegionEndpoint.USEast1);
var region = RegionEndpoint.GetBySystemName("us-west-2"); // use the region that you need
IdentityProvider = new AmazonCognitoIdentityProviderClient(null, region);