More in this section
Forums / General Discussions / Implementing Refresh Token

Implementing Refresh Token

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
1 posts, 0 answered
  1. Jagraphob
    Jagraphob avatar
    1 posts
    Registered:
    04 Apr 2016
    04 Apr 2016
    Link to this post

    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?

     

     

     

1 posts, 0 answered