title: An Authentication object was not found in the SecurityContext when @Scheduled triggered?
body: <p>I created a <code>Spring Boot</code> app and have trouble with some endpoints that can be triggered manually or via <code>@Scheduled</code> annotation.</p>
  
  <p>The issue I get is the one below:</p>
  
  <blockquote>
    <p>org.springframework.security.authentication.AuthenticationCredentialsNotFoundException:
    An Authentication object was not found in the SecurityContext</p>
  </blockquote>
  
  <p>Is there a way to trigger <code>SecurityContext</code> if the process called via <code>@Scheduled</code>?</p>
  
  <p>I am new to <code>Spring Security</code> and it is very hard for me to understand the reference guide. I found some similar questions but still cannot understand how to apply answers to my case.</p>
  
  <p>Example of my <code>MyController</code>:</p>
  
  <pre><code>@Secured("ROLE_ADMIN")
  @RestController
  @RequestMapping(value = "/api")
  public class MyController {
  
      @Scheduled(cron = "* * * * * *")
      @GetMapping(path="/data")
      public void getData() {
          // Do some operations
      }
  }
  </code></pre>