PHP code example of denniseilander / laravel-passport-scopes-restriction

1. Go to this page and download the library: Download denniseilander/laravel-passport-scopes-restriction library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

denniseilander / laravel-passport-scopes-restriction example snippets


// one scope
["read-users"]

// multiple scopes
["read-users","edit-users"]

// The same scopes are defined in the allowed_scopes column of the oauth_clients table
Passport::tokensCan([
    'scope-1' => 'Scope 1',
    'scope-2' => 'Scope 2',
    'scope-3' => 'Scope 3',
]);

POST /oauth/token ?scope=scope-1
bash
php artisan vendor:publish --provider="Denniseilander\PassportScopeRestriction\PassportClientServiceProvider" --tag="passport-scopes-restriction-migrations"
php artisan migrate
bash
php artisan vendor:publish --provider="Denniseilander\PassportScopeRestriction\PassportClientServiceProvider" --tag="passport-scopes-restriction-config"
bash
php artisan passport:scopes-sync
bash
php artisan passport:scopes-sync --keep-existing-scopes