title: Reading token with slimframework
body: <p>I'm using SlimFramework and JWT to handle token based authentication with login and password.</p>
  
  <p>I managed to login and send token in response.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>&lt;?php
  require_once("vendor/autoload.php");
  
  $app = new \Slim\Slim();
  $app-&gt;add(new \Slim\Middleware\ContentTypes());
  
  $app-&gt;post('/auth/login', function () use ($app) {
      $params = $app-&gt;request()-&gt;getBody();
      if ($params['email'] == "login" &amp;&amp; $params['password'] == "password") {
          $key = "example_key";
          $token = array(
              "id" =&gt; "1",
              "exp" =&gt; time() + (60 * 60 * 24)
          );
          $jwt = JWT::encode($token, $key);
          $app-&gt;response-&gt;headers-&gt;set('Content-Type', 'application/json');
          echo json_encode(array("token" =&gt; $jwt));
      }
  });
  
  $app-&gt;get("/user", function () {
      echo "ok";
  });
  $app-&gt;run();
  </code></pre>
  
  <ol>
  <li>How to check token in <code>/user</code> path?
  Making <code>/user</code> request I'm sending header with <code>Authorization:Bearer eHrR....</code></li>
  <li>And just for clearing - is that kind of auth (login and password) and OAuth the same? </li>
  </ol>