IssueRaiser

Laravel 5.5 + Vue.js 2 + JWT Auth 1.0.0-rc.1

Since I lost tons of time doing **tymon/jwt-auth** work in my application, I decided to share my code in this walkthrough. **FOR LARAVEL:** Add `"tymon/jwt-auth": "1.0.0-rc.1"` to **composer.json** and run `composer update` Add the service provider to the providers array in **config\app.php**: `Tymon\JWTAuth\Providers\LaravelServiceProvider::class` Add the facades to the aliases array also in **config/app.php**: ``` 'JWTAuth' => Tymon\JWTAuth\Facades\JWTAuth::class, 'JWTFactory' => Tymon\JWTAuth\Facades\JWTFactory::class ``` Run: `php artisan vendor:publish --provider="Tymon\JWTAuth\Providers\LaravelServiceProvider"` Run: `php artisan jwt:secret` If you are using CORS expose the response header "Authorization" to give JS allow getting header. Already if you are using Laravel CORS, then in config/cors.php specify expose the header: ``` ... 'exposedHeaders' => ['Authorization'], ... ``` The 1.0.0-rc.1 version requires you to implement _Tymon\JWTAuth\Contracts\JWTSubject_ on your user model too. You must then add the required methods, which are _getJWTIdentifier()_ and _getJWTCustomClaims()_ to **app\User.php**: ``` <?php namespace App; use Illuminate\Foundation\Auth\User as Authenticatable; use Tymon\JWTAuth\Contracts\JWTSubject; class User extends Authenticatable implements JWTSubject { /** * Get the identifier that will be stored in the subject claim of the JWT. * * @return mixed */ public function getJWTIdentifier() { ret

Posted by philliperosario on Oct 21, 2017, 11:10 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.4,500 issues0 comments

github (SaaS)

Laravel 5.5 + Vue.js 2 + JWT Auth 1.0.0-rc.1

philliperosarioOct 21, 2017, 11:10 PM

Since I lost tons of time doing **tymon/jwt-auth** work in my application, I decided to share my code in this walkthrough. **FOR LARAVEL:** Add `"tymon/jwt-auth": "1.0.0-rc.1"` to **composer.json** and run `composer update` Add the service provider to the providers array in **config\app.php**: `Tymon\JWTAuth\Providers\LaravelServiceProvider::class` Add the facades to the aliases array also in **config/app.php**: ``` 'JWTAuth' => Tymon\JWTAuth\Facades\JWTAuth::class, 'JWTFactory' => Tymon\JWTAuth\Facades\JWTFactory::class ``` Run: `php artisan vendor:publish --provider="Tymon\JWTAuth\Providers\LaravelServiceProvider"` Run: `php artisan jwt:secret` If you are using CORS expose the response header "Authorization" to give JS allow getting header. Already if you are using Laravel CORS, then in config/cors.php specify expose the header: ``` ... 'exposedHeaders' => ['Authorization'], ... ``` The 1.0.0-rc.1 version requires you to implement _Tymon\JWTAuth\Contracts\JWTSubject_ on your user model too. You must then add the required methods, which are _getJWTIdentifier()_ and _getJWTCustomClaims()_ to **app\User.php**: ``` <?php namespace App; use Illuminate\Foundation\Auth\User as Authenticatable; use Tymon\JWTAuth\Contracts\JWTSubject; class User extends Authenticatable implements JWTSubject { /** * Get the identifier that will be stored in the subject claim of the JWT. * * @return mixed */ public function getJWTIdentifier() { ret

Comments (0)

No comments yet. Start the discussion.

Comment on this issue