title: How to apply role base authorization to Web API 2 application that use token base authentication?
body: <p>I created a web API 2 application that used token-based authentication system. I used this <a href="http://bitoftech.net/2014/06/01/token-based-authentication-asp-net-web-api-2-owin-asp-net-identity/" rel="nofollow noreferrer">tutorial</a> to implement the authentication to the application.</p>
  
  <p>Then I added the roles to the system by using seed method.</p>
  
  <pre><code>        protected override void Seed(TBA.Models.AuthContext context)
          {
              if (!context.Roles.Any(r =&gt; r.Name == "SuperAdmin"))
              {
                  var store = new RoleStore&lt;IdentityRole&gt;(context);
                  var manager = new RoleManager&lt;IdentityRole&gt;(store);
                  var role = new IdentityRole { Name = "SuperAdmin" };
  
                  manager.Create(role);
              }
          }
  </code></pre>
  
  <p>Then I added the user to the user role.</p>
  
  <pre><code>        public async Task&lt;IdentityResult&gt; RegisterUser(UserModel userModel)
          {
              IdentityUser user = new IdentityUser
              {
                  UserName = userModel.UserName
              };
  
              var result =  await _userManager.CreateAsync(user, userModel.Password);
              await _userManager.AddToRoleAsync(user.Id, userModel.UserRole);
              return result;
          }
  </code></pre>
  
  <p>Then I try to access to below end-point.</p>
  
  <pre><code>        [Authorize(Roles = "SuperAdmin")]
          [Route("GetBySuperAdmin")]
          public IHttpActionResult GetBySuperAdmin()
          {
              return Ok("Get By Super Admin");
          }
  </code></pre>
  
  <p>It gives me below error message.</p>
  
  <pre><code>"message": "Authorization has been denied for this request."
  </code></pre>
  
  <p>What should I change to make this correct?
  How to check role before accessing the end-point in Web API 2 application?</p>