title: Symfony Console command : The token storage contains no authentication token
body: <p>When I try to launch my custom made Symfony command using php bin/console
  I get this bizarre error : </p>
  
  <blockquote>
    <p>[Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException]</p>
    
    <p>The token storage contains no authentication token. One possible
    reason may be that there is no firewall configured for this URL</p>
  </blockquote>
  
  <p>Its seem that the line responsible is </p>
  
  <pre><code>$user = $em-&gt;getRepository('CoreUserBundle:User')-&gt;findOneById($deck['user_id']);
              if ($user != null)
              {
                  $deck_entity = new Deck();
                  $deck_entity-&gt;SetId($deck['id']);
                  $deck_entity-&gt;SetUser($user);
                  $deck_entity-&gt;SetTitle($deck['titre']);
                  $deck_entity-&gt;SetClass($deck['classe']);
                  $deck_entity-&gt;SetStyle("None");
                  $deck_entity-&gt;SetContentHtml($deck['contenu_html']);
                  if (isset($deck['contenu_bbcode']))
                      $deck_entity-&gt;SetContentBBCode($deck['contenu_bbcode']);
                  $deck_entity-&gt;SetVideo($deck['video']);
                  $deck_entity-&gt;SetVersion($deck['version']);
                  $deck_entity-&gt;SetIsUpdated($deck['a_jour']);
                  $deck_entity-&gt;SetCraftCost($deck['craft_cout']);
                  $deck_entity-&gt;SetCreationDate(new \DateTime($deck['creation']));
                  $deck_entity-&gt;SetEditionDate(new \DateTime($deck['edition']));
                  $deck_entity-&gt;SetDeckType($deck['deck_type']);
  
  
                  $em-&gt;persist($deck_entity);
  
                  $metadata = $em-&gt;getClassMetaData(get_class($deck_entity));
                  $metadata-&gt;setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE);
              }
  </code></pre>
  
  <p><strong>UPDATE :</strong> Its seem that the error happen at the moment of persisting the entity Deck().</p>
  
  <p>My firewall security are </p>
  
  <pre><code>    firewalls:
      dev:
          pattern:  ^/(_(profiler|wdt)|css|images|js)/
          security: false
  
      main:
          pattern:  ^/
          form_login:
              login_path: /login
              provider: fos_userbundle
              csrf_token_generator: security.csrf.token_manager
              remember_me:   true
          oauth:
              resource_owners:
                  facebook: /login/check-facebook
                  google: /login/check-google
              login_path: /login
              failure_path: /login
              oauth_user_provider:
                  service: core.user.user_provider
          remember_me:
              secret:    "%secret%"
              name:      f1e56d001
              lifetime:  604800
              httponly:  true
              domain:    xxxx.eu
          logout:
              path:    fos_user_security_logout
              handlers: ['sonata.page.cms_manager_selector']
              target:  /
          anonymous:  true
          switch_user:
              role:       ROLE_ADMINISTRATOR
              parameter:  connect_as
  </code></pre>
  
  <p>I don't understand what I am supposed to, the error seem to tell me that i'm not authenticated, but how since I am using the console ?</p>
  
  <p>Thanks in advance.</p>