Implementing Refresh Token
Hi,
I am trying to utilize a Refresh Token in our application that uses Oauth authorization code flow. Since Sitefinity is not using OWIN so I can't do something like this to refresh the tokens and expire time.
if (DateTime.Now.ToLocalTime() >= (DateTime.Parse(identity.Claims.FirstOrDefault(c => c.ClaimType == "refresh_token").Value)))
var oaConfig = Config.Get<
OAuthConfig
>();
var tokenEndpointClient = new TokenClient(oaConfig.CompassHealthTokenEndpoint, oaConfig.CompassHealthAppId, oaConfig.CompassHealthAppSecretKey);
var tokenEndpointResponse = await tokenEndpointClient.RequestRefreshTokenAsync(identity.Claims.FirstOrDefault(c => c.ClaimType == "refresh_token").Value);
if (!tokenEndpointResponse.IsError)
var result = from claim in id.Claims where claim.ClaimType != "access_token" && claim.ClaimType != "refresh_token" && claim.ClaimType != "expires_at" select claim;
var claims = result.ToList();
claims.Add(new Claim("access_token", tokenEndpointResponse.AccessToken));
claims.Add(new Claim("expires_at", DateTime.Now.AddSeconds(tokenEndpointResponse.ExpiresIn).ToLocalTime().ToString()));
claims.Add(new Claim("refresh_token", tokenEndpointResponse.RefreshToken));
var newIdentity = new ClaimsIdentity(claims, "Cookies");
Request.GetOwinContext().Authentication.SignIn(newIdentity);
The GetOwincontext() method is not compatible with "Microsoft.IdentityModel.Claims" and I can't use "System.Security.Claims" because it's not compatible with Sitefinity.
What are my options with Sitefinity for refreshing token?