PHP code example of nddcoder / laravel-passport-iam

1. Go to this page and download the library: Download nddcoder/laravel-passport-iam 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/ */

    

nddcoder / laravel-passport-iam example snippets


return [
    'base_url' => env('PASSPORT_IAM_BASE_URL'),
    'path' => [
        'oauth_token' => 'oauth/token',
        'user' => 'api/user'
    ],
    'client_id' => env('PASSPORT_IAM_CLIENT_ID'),
    'client_secret' => env('PASSPORT_IAM_CLIENT_SECRET'),
    'common_fields' => explode(',', env('PASSPORT_IAM_COMMON_FIELDS')),
    'mapping_field' => [
        'iam' => 'uuid',
        'local' => 'uuid'
    ]
    
];

use Nddcoder\PassportIAM\Services\IAMServiceInterface;

$reponse = app(IAMServiceInterface::class)->login(['email' => '[email protected]', 'passord' => 'secret']);

/*
{
  "token_type": "Bearer",
  "expires_in": 2592000,
  "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsI...",
  "refresh_token": "def50200ffa17b51e9e46117..."
}
*/

Route::group(['middleware' => ['auth:api']], function () {
    Route::get('/me', function(Request $request) {
        return $request->user();
    })
});
bash
php artisan vendor:publish --provider="Nddcoder\PassportIAM\IAMServiceProvider" --tag="config"