Skip to content

Commit 10ca661

Browse files
[12.x] Update Passport documentation (#10439)
* fix a typo * formatting * Update passport.md --------- Co-authored-by: Taylor Otwell <taylor@laravel.com>
1 parent 00a4c0f commit 10ca661

File tree

2 files changed

+29
-20
lines changed

2 files changed

+29
-20
lines changed

‎passport.md

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ To get started, we need to instruct Passport how to return our "authorization" v
255255
All the authorization view's rendering logic may be customized using the appropriate methods available via the `Laravel\Passport\Passport` class. Typically, you should call this method from the `boot` method of your application's `App\Providers\AppServiceProvider` class:
256256

257257
```php
258+
use Inertia\Inertia;
258259
use Laravel\Passport\Passport;
259260

260261
/**
@@ -638,6 +639,7 @@ To get started, we need to instruct Passport how to return our "user code" and "
638639
All the authorization view's rendering logic may be customized using the appropriate methods available via the `Laravel\Passport\Passport` class. Typically, you should call this method from the `boot` method of your application's `App\Providers\AppServiceProvider` class.
639640

640641
```php
642+
use Inertia\Inertia;
641643
use Laravel\Passport\Passport;
642644

643645
/**
@@ -650,15 +652,19 @@ public function boot(): void
650652
Passport::deviceAuthorizationView('auth.oauth.device.authorize');
651653

652654
// By providing a closure...
653-
Passport::deviceUserCodeView(fn ($parameters) => Inertia::render('Auth/OAuth/Device/UserCode'));
655+
Passport::deviceUserCodeView(
656+
fn ($parameters) => Inertia::render('Auth/OAuth/Device/UserCode')
657+
);
654658

655-
Passport::deviceAuthorizationView(fn ($parameters) => Inertia::render('Auth/OAuth/Device/Authorize', [
656-
'request' => $parameters['request'],
657-
'authToken' => $parameters['authToken'],
658-
'client' => $parameters['client'],
659-
'user' => $parameters['user'],
660-
'scopes' => $parameters['scopes'],
661-
]));
659+
Passport::deviceAuthorizationView(
660+
fn ($parameters) => Inertia::render('Auth/OAuth/Device/Authorize', [
661+
'request' => $parameters['request'],
662+
'authToken' => $parameters['authToken'],
663+
'client' => $parameters['client'],
664+
'user' => $parameters['user'],
665+
'scopes' => $parameters['scopes'],
666+
])
667+
);
662668

663669
// ...
664670
}
@@ -738,7 +744,7 @@ do {
738744
$response = Http::asForm()->post('https://passport-app.test/oauth/token', [
739745
'grant_type' => 'urn:ietf:params:oauth:grant-type:device_code',
740746
'client_id' => 'your-client-id',
741-
'client_secret' => 'your-client-secret', // required for confidential clients only
747+
'client_secret' => 'your-client-secret', // Required for confidential clients only...
742748
'device_code' => 'the-device-code',
743749
]);
744750

@@ -792,7 +798,7 @@ use Illuminate\Support\Facades\Http;
792798
$response = Http::asForm()->post('https://passport-app.test/oauth/token', [
793799
'grant_type' => 'password',
794800
'client_id' => 'your-client-id',
795-
'client_secret' => 'your-client-secret', // required for confidential clients only
801+
'client_secret' => 'your-client-secret', // Required for confidential clients only...
796802
'username' => 'taylor@laravel.com',
797803
'password' => 'my-password',
798804
'scope' => 'user:read orders:create',
@@ -815,7 +821,7 @@ use Illuminate\Support\Facades\Http;
815821
$response = Http::asForm()->post('https://passport-app.test/oauth/token', [
816822
'grant_type' => 'password',
817823
'client_id' => 'your-client-id',
818-
'client_secret' => 'your-client-secret', // required for confidential clients only
824+
'client_secret' => 'your-client-secret', // Required for confidential clients only...
819825
'username' => 'taylor@laravel.com',
820826
'password' => 'my-password',
821827
'scope' => '*',
@@ -839,9 +845,10 @@ namespace App\Models;
839845

840846
use Illuminate\Foundation\Auth\User as Authenticatable;
841847
use Illuminate\Notifications\Notifiable;
848+
use Laravel\Passport\Contracts\OAuthenticatable;
842849
use Laravel\Passport\HasApiTokens;
843850

844-
class User extends Authenticatable
851+
class User extends Authenticatable implements OAuthenticatable
845852
{
846853
use HasApiTokens, Notifiable;
847854

@@ -868,9 +875,10 @@ namespace App\Models;
868875
use Illuminate\Foundation\Auth\User as Authenticatable;
869876
use Illuminate\Notifications\Notifiable;
870877
use Illuminate\Support\Facades\Hash;
878+
use Laravel\Passport\Contracts\OAuthenticatable;
871879
use Laravel\Passport\HasApiTokens;
872880

873-
class User extends Authenticatable
881+
class User extends Authenticatable implements OAuthenticatable
874882
{
875883
use HasApiTokens, Notifiable;
876884

@@ -1127,9 +1135,9 @@ If a client does not request any specific scopes, you may configure your Passpor
11271135
use Laravel\Passport\Passport;
11281136

11291137
Passport::tokensCan([
1130-
'user:read' => 'Retrieve the user info',
1131-
'orders:create' => 'Place orders',
1132-
'orders:read:status' => 'Check order status',
1138+
'user:read' => 'Retrieve the user info',
1139+
'orders:create' => 'Place orders',
1140+
'orders:read:status' => 'Check order status',
11331141
]);
11341142

11351143
Passport::defaultScopes([
@@ -1305,6 +1313,7 @@ Passport raises events when issuing access tokens and refresh tokens. You may [l
13051313
| Event Name |
13061314
| --- |
13071315
| `Laravel\Passport\Events\AccessTokenCreated` |
1316+
| `Laravel\Passport\Events\AccessTokenRevoked` |
13081317
| `Laravel\Passport\Events\RefreshTokenCreated` |
13091318

13101319
</div>

‎upgrade.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,10 @@ The `Schema::getTables()`, `Schema::getViews()`, and `Schema::getTypes()` method
160160
$tables = Schema::getTables();
161161

162162
// All tables on the 'main' schema...
163-
$table = Schema::getTables(schema: 'main');
163+
$tables = Schema::getTables(schema: 'main');
164164

165165
// All tables on the 'main' and 'blog' schemas...
166-
$table = Schema::getTables(schema: ['main', 'blog']);
166+
$tables = Schema::getTables(schema: ['main', 'blog']);
167167
```
168168

169169
The `Schema::getTableListing()` method now returns schema-qualified table names by default. You may pass the `schemaQualified` argument to change the behavior as desired:
@@ -172,10 +172,10 @@ The `Schema::getTableListing()` method now returns schema-qualified table names
172172
$tables = Schema::getTableListing();
173173
// ['main.migrations', 'main.users', 'blog.posts']
174174

175-
$table = Schema::getTableListing(schema: 'main');
175+
$tables = Schema::getTableListing(schema: 'main');
176176
// ['main.migrations', 'main.users']
177177

178-
$table = Schema::getTableListing(schema: 'main', schemaQualified: false);
178+
$tables = Schema::getTableListing(schema: 'main', schemaQualified: false);
179179
// ['migrations', 'users']
180180
```
181181

0 commit comments

Comments
 (0)