aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Web/TangoWebClient.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/Tango.Web/TangoWebClient.cs')
-rw-r--r--Software/Visual_Studio/Tango.Web/TangoWebClient.cs23
1 files changed, 20 insertions, 3 deletions
diff --git a/Software/Visual_Studio/Tango.Web/TangoWebClient.cs b/Software/Visual_Studio/Tango.Web/TangoWebClient.cs
index 42a9d801c..08fc19099 100644
--- a/Software/Visual_Studio/Tango.Web/TangoWebClient.cs
+++ b/Software/Visual_Studio/Tango.Web/TangoWebClient.cs
@@ -5,7 +5,7 @@ using System.Security.Authentication;
using System.Text;
using System.Threading.Tasks;
using Tango.Transport.Web;
-using Tango.Web.Authentication;
+using Tango.Web.Security;
namespace Tango.Web
{
@@ -70,13 +70,29 @@ namespace Tango.Web
return response;
}
+ private async Task Renew()
+ {
+ var response = await _client.PostJson<RenewTokenRequest, RenewTokenResponse>(GetActionAddress("Renew"), new RenewTokenRequest()
+ {
+ RefreshToken = WebToken.RefreshToken,
+ });
+
+ Token = response.AccessToken;
+ _client.AuthenticationToken = Token;
+
+ WebToken = WebToken.FromToken(Token);
+
+ IsAuthenticated = true;
+ }
+
protected virtual async Task<TResponse> Post<TRequest, TResponse>(String action, TRequest request) where TRequest : class, IWebRequestMessage where TResponse : class, IWebResponseMessage
{
if (IsAuthenticated)
{
if (DateTime.UtcNow >= WebToken.Expiration)
{
- await Login(_lastLoginRequest);
+ await Renew();
+ //await Login(_lastLoginRequest);
}
}
@@ -89,7 +105,8 @@ namespace Tango.Web
{
try
{
- await Login(_lastLoginRequest);
+ //await Login(_lastLoginRequest);
+ await Renew();
var response = await _client.PostJson<TRequest, TResponse>(GetActionAddress(action), request);
return response;
}