title: Determine if bearer token has expired or is just authorized
body: <p>My angular application is making use of bearer tokens as outlined in the article series <a href="http://bitoftech.net/2014/06/01/token-based-authentication-asp-net-web-api-2-owin-asp-net-identity/">http://bitoftech.net/2014/06/01/token-based-authentication-asp-net-web-api-2-owin-asp-net-identity/</a>.  I have followed the forked example to seamlessly refresh tokens when the access token has expired (via 401 http code).</p>
  
  <p>My question is how can I determine if the bearer token is expired or just plain unauthorized based on the role determined?</p>
  
  <p>For example, my web api method has the attribute [Authorize(Roles="Admin")].  When I make a call to that, I get back my 401 error, which is expected.  However, when my access token expires and I make another web api method call, it also returns a 401 error.  Heres my responseError handler in my interceptor:</p>
  
  <pre><code>        responseError: function (rejection) {
              var deferred = q.defer();
              if (rejection.status === 401) {
                  var authService = $injector.get('authService');
                  authService.refreshToken().then(function (response) {
                      _retryHttpRequest(rejection.config, deferred);
                  }, function () {
                      authService.logOut();
                      $location.path('/dashboard');
                      deferred.reject(rejection);
                  });
              } else {
                  deferred.reject(rejection);
              }
              return deferred.promise;
          }
  </code></pre>
  
  <p>I was playing around with different things but basically, I'd like to refresh my token and resend my request when the access token has expired; however, I don't want to refresh my token if it truly is a denied request due to the role specified.  </p>
  
  <p>Any thoughts?</p>