Anonymous
Not logged in
Talk
Contributions
Create account
Log in
DocsMaulana
Search
Editing
Cara menambahkan JWT di laravel Passport
From DocsMaulana
Namespaces
Page
Discussion
More
More
Page actions
Read
Edit
Edit source
History
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
# Install laravel seperti biasa<blockquote>composer create-project laravel/laravel example-app</blockquote> # Tambahkan library passport<blockquote>composer require laravel/passport</blockquote> # Silahkan setting database di file env dan setting field migrasi user sebelum melakukan migrasi. # Lakukan migrasi<blockquote>php artisan migrate</blockquote>5. Setelah sukses migrasi database, langkah selanjutnya adalah membuat '''''token keys''''' dengan perintah:<blockquote>php artisan passport:install Perintah di atas akan mengenerate ''token keys'' dan disimpan di dalam database. 6. Ubah file <code>app/models/User.php</code> menjadi seperti berikut:<blockquote>use Laravel\Sanctum\HasApiTokens;</blockquote>ubah jadi<blockquote>use Laravel\Passport\HasApiTokens;</blockquote>7. Tambahkan auth di file <code>app/config/auth.php</code><blockquote>'guards' => [ // kode lain 'api' => [ 'driver' => 'passport', 'provider' => 'users', ], ]</blockquote>8. tambahkan route dengan middleware<blockquote>Route::middleware('auth:api')->group( function () { // route di dalam middleware });</blockquote>
Summary:
Please note that all contributions to DocsMaulana may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Docs Maulana:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation
Navigation
Main page
Laravel
Recent changes
Wiki tools
Wiki tools
Special pages
Page tools
Page tools
User page tools
More
What links here
Related changes
Page information
Page logs