Get started
Install Angular Install Motivation
Tutorial
Overview TDD Model setup API routes Angular Http Angular Auth
Response Macros
Overview Validations
JWT Authentication
Overview Install Usage

This project has been archived. If you're curious, check out one of my latest courses:

If you work with JavaScript, check out the fetch use cases and JavaScript projects.

Thank you! — Jad Joubran

Adding Authentication

This step of the tutorial covers adding Json Web Token authentication to your project.

JWT Auth setup

Assuming you've follwed the JWT installation steps, follow the instructions below to require authentication when accessing the api/posts endpoint.

Replace your previous API route with one the ways below:

routes/api.php
Route::middleware('auth:api')->get('/posts', 'PostsController@index');
//or
Route::group(['middleware' => 'auth:api'], function () {
 Route::get('/posts', 'PostsController@index');
});

Voila! You will need to provide an Authorization header to be able to access this endpoint.

Creating tokens

Make sure to follow the JWT Usage docs in order to generate tokens, check for authentication and more.

AltStyle によって変換されたページ (->オリジナル) /