File tree Expand file tree Collapse file tree 1 file changed +15
-8
lines changed Expand file tree Collapse file tree 1 file changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ class User extends Authenticatable
4747
4848```
4949
50- Next create a User.
50+ Next create a User. Easiest to to this part in tinker.
5151``` php
5252$user = User::create([
5353 'name' => 'Ed Anisko',
@@ -65,11 +65,13 @@ Auth::setUser($user);
6565
6666Now the package will create ApiKeys for the authorized user.
6767``` php
68- LaravelApiKeys::create(LaravelApiKeyType::PRODUCTION ); // default is SANDBOX
68+ LaravelApiKeys::create(); // default is SANDBOX
6969```
70+ Copy the new api key.
71+
7072
7173## Using the your API Keys
72- Change the guards section of config/auth.php
74+ Add the new entry to the guards section of config/auth.php
7375``` php
7476 'guards' => [
7577 'web' => [
@@ -78,23 +80,28 @@ Change the guards section of config/auth.php
7880 ],
7981
8082 'api' => [
81- 'driver' => 'lak ',
83+ 'driver' => 'token ',
8284 'provider' => 'users',
83- 'hash' => true ,
85+ 'hash' => false ,
8486 ],
8587
88+ "api_key" => [
89+ 'driver' => 'api_key'
90+ ]
91+
8692 ]
8793```
8894
8995
90- Use the 'auth: lak ' middleware in api.php routes.
96+ Use the 'auth: api_key ' middleware in api.php routes.
9197``` php
92- Route::middleware('auth:lak ')->get('/user', function (Request $request) {
98+ Route::middleware('auth:api_key ')->get('/user', function (Request $request) {
9399 return $request->user();
94100});
95101```
96102
97- Replace the x-api-key header with your own api-key and test..
103+ Replace the x-api-key header with your own api-key and test.
104+ Use the header Accept: application/json.
98105``` bash
99106
100107$ curl -X GET \
You can’t perform that action at this time.
0 commit comments