@@ -164,6 +164,9 @@ Laravel Passport is an OAuth 2.0 server implementation that offers
164
164
API authentication for Laravel applications. Use Laravel Passport if
165
165
your application requires OAuth2 support.
166
166
167
+ Install Laravel Passport
168
+ ````````````````````````
169
+
167
170
To install Laravel Passport and run the database migrations required
168
171
to store OAuth2 clients, run the following command from your project root:
169
172
@@ -212,10 +215,23 @@ to the ``guards`` array:
212
215
],
213
216
],
214
217
215
- Lastly, you must override the default Laravel Passport models by defining a custom model
216
- that extends the corresponding Laravel Passport model. by including the ``DocumentModel`` trait. This trait allows you
217
- to make Laravel Passport compatible with MongoDB. The following code defines
218
- a series of model classes that extend the corresponding ``Laravel\Passport`` models:
218
+ Use Laravel Passport with {+odm-short+}
219
+ ```````````````````````````````````````
220
+
221
+ After installing Laravel Passport, you must enable Passport compatibility with MongoDB by
222
+ defining custom {+odm-short+} models that extend the corresponding Passport models.
223
+ To extend each Passport model class, include the ``DocumentModel`` trait in the custom models.
224
+ You can define the following {+odm-short+} model classes:
225
+
226
+ - ``MongoDB\Laravel\Passport\AuthCode``, which extends ``Laravel\Passport\AuthCode``
227
+ - ``MongoDB\Laravel\Passport\Client``, which extends ``Laravel\Passport\Client``
228
+ - ``MongoDB\Laravel\Passport\PersonalAccessClient``, which extends ``Laravel\Passport\PersonalAccessClient``
229
+ - ``MongoDB\Laravel\Passport\RefreshToken``, which extends ``Laravel\Passport\RefreshToken``
230
+ - ``MongoDB\Laravel\Passport\Token``, which extends ``Laravel\Passport\Token``
231
+
232
+ For example, the following code overrides the default ``Laravel\Passport\AuthCode``
233
+ model class by defining a ``MongoDB\Laravel\Passport\AuthCode`` class and including
234
+ the ``DocumentModel`` trait:
219
235
220
236
.. code-block:: php
221
237
@@ -227,10 +243,14 @@ a series of model classes that extend the corresponding ``Laravel\Passport`` mod
227
243
protected $keyType = 'string';
228
244
}
229
245
230
- class MongoDB\Laravel\Passport\Client extends Laravel\Passport\Client;
231
- class MongoDB\Laravel\Passport\PersonalAccessClient extends Laravel\Passport\PersonalAccessClient;
232
- class MongoDB\Laravel\Passport\RefreshToken extends Laravel\Passport\RefreshToken;
233
- class MongoDB\Laravel\Passport\Token extends Laravel\Passport\Token;
246
+ After defining a custom model, instruct Passport to use the model in the ``boot``
247
+ method of your application's ``App\Providers\AppServiceProvider`` class, as shown
248
+ in the following code:
249
+
250
+ .. literalinclude:: /includes/auth/PersonalAccessToken.php
251
+ :language: php
252
+ :emphasize-lines: 6,23
253
+ :dedent:
234
254
235
255
You can now use Laravel Passport and MongoDB in your application. For more information, see
236
256
`Laravel Passport <https://laravel.com/docs/{+laravel-docs-version+}/passport>`__ in the
0 commit comments