public async Task <bool> UpdateToken()
        {
            var userInfo = await JsRuntime.GetUserInfoAsync();

            var response = await RefreshToken(userInfo.RefreshToken);

            if (!response.IsSuccessStatusCode)
            {
                await JsRuntime.RemoveUserInfoAsync();

                return(false);
            }

            var result =
                JsonConvert.DeserializeObject <AuthSuccessResponse>(await response.Content.ReadAsStringAsync());
            await JsRuntime.SetUserInfoAsync(new UserInfo
                                             { Token = result.Token, RefreshToken = result.RefreshToken, Email = userInfo.Email });

            return(true);
        }
        public async Task <string> GetToken()
        {
            var userInfo = await JsRuntime.GetUserInfoAsync();

            if (!string.IsNullOrWhiteSpace(userInfo?.Token))
            {
                return(userInfo.Token);
            }

            if (string.IsNullOrWhiteSpace(userInfo?.RefreshToken))
            {
                return(null);
            }

            if (await UpdateToken())
            {
                userInfo = await JsRuntime.GetUserInfoAsync();
            }

            return(userInfo.Token);
        }