private void Renew(AdalAccessToken token)
{
if (IsExpired(token))
{
var context = CreateContext(token.Configuration);
try
{
var authResult = context.AcquireTokenByRefreshToken(GetRefreshToken(token),
token.Configuration.ClientId,
token.Configuration.ResourceClientUri);
if (authResult == null)
{
throw new Exception(Resources.ExpiredRefreshToken);
}
token.AuthResult = authResult;
}
catch (Exception ex)
{
throw new AadAuthenticationCantRenewException(Resources.ExpiredRefreshToken, ex);
}
}
}