身份变更后,AWS Cognito Sync失败

时间:2017-11-29 05:36:52

标签: c# amazon-web-services xamarin amazon-cognito

我正在努力将AWS Cognito Sync集成到Xamarin应用程序中。只要身份验证状态不变,一切都适用于未经身份验证和身份验证的情况。如果用户注销并再次登录,则CognitoSync在登录后无法恢复。一旦用户重新启动应用程序,情况就再好了,但这几乎不是解决方案......

遗憾的是,在凭据更改后,我无法找到有关CognitoSync端需要执行的操作的更多信息。 CognitoAwsCredentials从RefreshingAWSCredentials扩展而来,据我所知,我只需更新该实例并清除其缓存。

登录时:

CognitoAwsCredentials.AddLogin(providerName, idToken);
CognitoAwsCredentials.ClearCredentials(); // Clear cached credentials

退出时:

foreach (var provider in CognitoAwsCredentials.CurrentLoginProviders.ToArray())
    CognitoAwsCredentials.RemoveLogin(provider);
CognitoAwsCredentials.Clear();  // get a new identity id

登录后明确调用CognitoAwsCredentials.GetCredentialsAsync()会导致以下异常:

Amazon.CognitoSync.SyncManager.Internal.Sqlite3Exception: Error executing statement Constraint
  at Amazon.CognitoSync.SyncManager.Internal.SQLiteLocalStorage.Execute (System.String query, System.Object[] parameters) [0x000b1] in <62c37bae57154a9db28b11672ef24676>:0 
  at Amazon.CognitoSync.SyncManager.Internal.SQLiteLocalStorage.ExecuteMultipleHelper (System.Collections.Generic.List`1[T] statements) [0x00036] in <62c37bae57154a9db28b11672ef24676>:0 
  at Amazon.CognitoSync.SyncManager.Internal.SQLiteLocalStorage.ChangeIdentityId (System.String oldIdentityId, System.String newIdentityId) [0x0031c] in <62c37bae57154a9db28b11672ef24676>:0 
  at Amazon.CognitoSync.SyncManager.CognitoSyncManager.IdentityChanged (System.Object sender, System.EventArgs e) [0x0004f] in <62c37bae57154a9db28b11672ef24676>:0 
  at (wrapper delegate-invoke) System.EventHandler`1[Amazon.CognitoIdentity.CognitoAWSCredentials+IdentityChangedArgs]:invoke_void_object_TEventArgs (object,Amazon.CognitoIdentity.CognitoAWSCredentials/IdentityChangedArgs)
  at Amazon.CognitoIdentity.CognitoAWSCredentials.UpdateIdentity (System.String newIdentityId) [0x0003d] in <582789cfd3e945e89e215d9a53e2bee6>:0 
  at Amazon.CognitoIdentity.CognitoAWSCredentials+<GetPoolCredentialsAsync>d__59.MoveNext () [0x001c3] in <582789cfd3e945e89e215d9a53e2bee6>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
  at Amazon.CognitoIdentity.CognitoAWSCredentials+<GenerateNewCredentialsAsync>d__57.MoveNext () [0x00126] in <582789cfd3e945e89e215d9a53e2bee6>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
  at Amazon.Runtime.RefreshingAWSCredentials+<GetCredentialsAsync>d__8.MoveNext () [0x00035] in E:\JenkinsWorkspaces\v3-trebuchet-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Credentials\RefreshingAWSCredentials.cs:104 

在尝试通过在登录后调用DataSet.Put(...)来存储值时,也会抛出与Sqlite相关的异常:

Amazon.CognitoSync.SyncManager.Internal.Sqlite3Exception: Error executing statement Error
  at Amazon.CognitoSync.SyncManager.Internal.SQLiteLocalStorage.Execute (System.String query, System.Object[] parameters) [0x000b1] in <62c37bae57154a9db28b11672ef24676>:0 
  at Amazon.CognitoSync.SyncManager.Internal.SQLiteLocalStorage.ExecuteMultipleHelper (System.Collections.Generic.List`1[T] statements) [0x00000] in <62c37bae57154a9db28b11672ef24676>:0 
  at Amazon.CognitoSync.SyncManager.Internal.SQLiteLocalStorage.PutValueHelper (System.String identityId, System.String datasetName, System.String key, System.String value) [0x00198] in <62c37bae57154a9db28b11672ef24676>:0 
  at Amazon.CognitoSync.SyncManager.Internal.SQLiteLocalStorage.PutValue (System.String identityId, System.String datasetName, System.String key, System.String value) [0x00010] in <62c37bae57154a9db28b11672ef24676>:0 
  at Amazon.CognitoSync.SyncManager.Dataset.Put (System.String key, System.String value) [0x00018] in <62c37bae57154a9db28b11672ef24676>:0 

有什么想法吗?

0 个答案:

没有答案