title: How to pass Enum as string parameter to Authorize attribute?
body: <p>It's my first project to ASP.NET Core Authentication and Authorization and I get this error when I'm trying to pass Enum to [Authorize] attribute :</p>
  <blockquote>
  <p>Error CS1503  Argument 1: cannot convert from
  'BasicAuthAPI.Entities.Role' to
  'string'</p>
  </blockquote>
  <p>Here is my controller method which gives this error:</p>
  <pre><code>[Authorize(Role.Admin)]
  [HttpGet]
  public IActionResult GetAll()
  {
       var users = _userService.GetAll();
       return Ok(users);
  }
  </code></pre>
  <p>Role enum:</p>
  <pre><code>public enum Role
      {
          Admin,
          User
      }
  </code></pre>
  <p>User Entity:</p>
  <pre><code>public class User
      {
          public int Id { get; set; }
          public string FirstName { get; set; }
          public string LastName { get; set; }
          public string Username { get; set; }
          public Role Role { get; set; }
  
          [JsonIgnore]
          public string PasswordHash { get; set; }
      }
  </code></pre>
  <p>And the _userService which I have mentioned in controller:</p>
  <pre><code>public class UserService : IUserService
      {
          private DataContext _context;
          private IJwtUtils _jwtUtils;
          private readonly AppSettings _appSettings;
  
          public UserService(
              DataContext context,
              IJwtUtils jwtUtils,
              IOptions&lt;AppSettings&gt; appSettings)
          {
              _context = context;
              _jwtUtils = jwtUtils;
              _appSettings = appSettings.Value;
          }
  
  
          public AuthenticateResponse Authenticate(AuthenticateRequest model)
          {
              var user = _context.Users.SingleOrDefault(x =&gt; x.Username == model.Username);
  
              // validate
              if (user == null || !BCryptNet.Verify(model.Password, user.PasswordHash))
                  throw new AppException(&quot;Username or password is incorrect&quot;);
  
              // authentication successful so generate jwt token
              var jwtToken = _jwtUtils.GenerateJwtToken(user);
  
              return new AuthenticateResponse(user, jwtToken);
          }
  
          public IEnumerable&lt;User&gt; GetAll()
          {
              return _context.Users;
          }
  
          public User GetById(int id)
          {
              var user = _context.Users.Find(id);
              if (user == null) throw new KeyNotFoundException(&quot;User not found&quot;);
              return user;
          }
      }
  </code></pre>
  <p>How can I pass the Admin Role to [Authorize] attribute?</p>