Hi, when access user db synced i receive a invalid session, and comparing user.AccessToken == user.RefreshToken it’s diferent, and I want update user credential with refreshtoken ( Class User | Realm ) but i can’t find a method to do it.
I don’t want force logout and user made login again.
What method are you using when you get invalid session? Realm will automatically refresh credentials based on server error codes, so you should not experience disruptions in sync because of expired access tokens. The Access and Refresh token properties on the user object are expected to be different and it is not a bug that they are.
Hi @nirinchev ,
I receive Invalid Session in this two cases below, but it’s strange because i can access data with UserExtension = realmInstance.All().Where(u => u._id == realmUser.Id).FirstOrDefault();
the errors occurs in
**await App.AppEnvironmentService.SyncDB.RealmInstance.GetSession().WaitForDownloadAsync();**
InvalidSession
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Realms.Sync.SessionHandle.<WaitAsync>d__8.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at LexSemanticClient.ViewModel.LoginViewModel.<WaitSync>d__81.MoveNext() in C:\Users\scf\source\repos\Utilities\LexSemanticClient\LexSemanticClient\ViewModel\LoginViewModel.cs:line 628
**await user.RefreshCustomDataAsync();**
InvalidSession: invalid session: refresh token expired
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Realms.Sync.SyncUserHandle.<RefreshCustomDataAsync>d__10.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Realms.Sync.User.<RefreshCustomDataAsync>d__31.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at LexSemanticAppSyncPersistence.Database.<GetCurrentUserExtension>d__21.MoveNext() in C:\Users\scf\source\repos\Utilities\LexSemanticAppSyncPersistence\Database.cs:line 183
I think UserExtension = realmInstance.All().Where(u => u._id == realmUser.Id).FirstOrDefault(); is working because instance is created as Realm.GetInstance(RealmSyncConfig) , only first time open is made with await Realm.GetInstanceAsync(RealmSyncConfig) , i tried to use it but receive same Invalid Session.