title: ASPNet Core: Use [Authorize] with function in service
body: <p>I am using JwtBearer authentication to secure my API. I am adding <code>[Authorize]</code> above each API and it worked. </p>
  
  <p>I am using this code to add the authentication in the startup: </p>
  
  <pre><code>services.AddAuthentication("Bearer")
          .AddJwtBearer("Bearer", options =&gt;
          {
              options.Authority = "http://localhost:1234";
              options.RequireHttpsMetadata = false;
              options.Audience = "test";
          });
  </code></pre>
  
  <p>I want a way to add the <code>[Authorize]</code> to a function in a service, or write a code in the function that works the same as <code>[Authorize]</code>.</p>