title: How to fix Unauthorized access on POST /oauth/token
body: <p>I am trying to make demo of SPA app in Vue.js which communicates with backend API made in laravel 5.4 with passport and oauth.
  I am passing along with tutorial on <a href="https://www.youtube.com/watch?v=JEn16aQoowE&amp;list=PLkZU2rKh1mT9TgMvpFY1QVrX2z4I3D3Jq&amp;index=1" rel="nofollow noreferrer">https://www.youtube.com/watch?v=JEn16aQoowE&amp;list=PLkZU2rKh1mT9TgMvpFY1QVrX2z4I3D3Jq&amp;index=1</a></p>
  
  <p>The only difference is that my backend API has Custom User Provider to simulate autehntication to another database table via table view.</p>
  
  <p>POST to <code>http://127.0.0.1:8000/oauth/token</code> gives me following eror:   </p>
  
  <blockquote>
    <p>Response {url: "<a href="http://127.0.0.1:8000/oauth/token" rel="nofollow noreferrer">http://127.0.0.1:8000/oauth/token</a>", ok: false, status: 401, statusText: "Unauthorized", headers: Headers…}</p>
  </blockquote>
  
  <p>Here is how to reproduce it:</p>
  
  <ol>
  <li><p>Setup backend API:
  <code>
  git clone https://github.com/gandra/laravel54-passport-demo-external-user
  cd laravel54-passport-demo-external-user
  cp .env.example .env
  composer install
  php artisan key:generate
  npm install
  npm run dev
  php artisan migrate
  php artisan db:seed
  php artisan passport:install
  </code></p></li>
  <li><p>Update your <code>laravel54-passport-demo-external-user/.env</code> file with your database info</p></li>
  <li><p>Bring up API server with:<br>
  <code>
  php artisan serve
  </code></p></li>
  <li><p>Setup frontend:<br>
  <code>
  git clone https://github.com/gandra/laravel54-passport-demo-vue-client.git
  cd laravel54-passport-demo-vue-client
  npm install
  </code></p></li>
  <li><p>Update client secret in <code>laravel54-passport-demo-vue-client\src\App.vue</code> with value of <code>secret</code> field from table <code>oauth_clients</code> where name = 'Laravel Password Grant Client' </p></li>
  <li><p>Bring up frontend:
  <code>
  npm run dev
  </code>
  This should open url <code>http://localhost:8080/</code> in browser. Open browser console and check for error. You will see something like this:</p></li>
  </ol>
  
  <p><a href="https://i.stack.imgur.com/tt1Vd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tt1Vd.png" alt="enter image description here"></a></p>
  
  <p>Here is the error log from laravel: 
  <a href="https://gist.github.com/gandra/f3a45a638df036e280303ff6d94a89d0" rel="nofollow noreferrer">https://gist.github.com/gandra/f3a45a638df036e280303ff6d94a89d0</a>
  and another one when tried with other client: 
  <a href="https://gist.github.com/gandra/8da758ad223916613c0604817c2e1130" rel="nofollow noreferrer">https://gist.github.com/gandra/8da758ad223916613c0604817c2e1130</a></p>