diff --git a/Storage/Storage.Test/UserTest.cs b/Storage/Storage.Test/UserTest.cs index ac652d52..728316f9 100644 --- a/Storage/Storage.Test/UserTest.cs +++ b/Storage/Storage.Test/UserTest.cs @@ -320,6 +320,16 @@ public async Task QueryUser() { } } + [Test] + [Order(19)] + public async Task RefreshSessionToken() { + LCUser user = await LCUser.Login(TestPhone, TestPhone); + string oldToken = user.SessionToken; + await user.RefreshSessionToken(); + string newToken = user.SessionToken; + Assert.AreNotEqual(oldToken, newToken); + } + private string GetTestEmail() { return $"{TestPhone}@leancloud.rocks"; } diff --git a/Storage/Storage/Public/User/LCUser.cs b/Storage/Storage/Public/User/LCUser.cs index ff79eb57..b5eee2d1 100644 --- a/Storage/Storage/Public/User/LCUser.cs +++ b/Storage/Storage/Public/User/LCUser.cs @@ -438,6 +438,13 @@ public static async Task BecomeWithSessionToken(string sessionToken) { return currentUser; } + public async Task RefreshSessionToken() { + string path = $"users/{ObjectId}/refreshSessionToken"; + Dictionary response = await LCCore.HttpClient.Put>(path); + SessionToken = response["sessionToken"] as string; + await _SaveToLocal(); + } + /// /// Requests a password reset email to be sent to a user's email address. ///