PHP code example of laradevs / authremote

1. Go to this page and download the library: Download laradevs/authremote 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/ */

    

laradevs / authremote example snippets


// config/app.php

'Providers' => [
   // ...
    \LaraDevs\AuthRemote\MainServiceProvider::class,
]

return [
    'uri' => env('USER_PROVIDER_REST_URL', ''),
    'name_session_rest' => 'token_oauth',
    'headers' => [],
    'route_not_session'=>'start_route'
];

'laravelpassport' => [
        'client_id' => env('LARAVELPASSPORT_KEY','http://YOUR_ROUTE_HOST_SERVER/api/user'),
        'client_secret' => env('LARAVELPASSPORT_SECRET'),
        'redirect' => env('LARAVELPASSPORT_REDIRECT_URI'),
        'host'=> env('LARAVELPASSPORT_HOST')
    ]

 if ($exception instanceof \LaraDevs\AuthRemote\RestException) {
            return redirect()->route(config('rest-provider.route_not_session'));
 }

  'providers' => [
        'users' => [
            'driver' => 'rest-users',
            'model' => \LaraDevs\AuthRemote\User::class
        ],
  ]

Route::get('/auth-remote/{provider}', '\LaraDevs\AuthRemote\ActionsController@redirectToProvider')->name('laravel_passport');
Route::get('/auth-remote/{provider}/callback', '\LaraDevs\AuthRemote\ActionsController@handleProviderCallback');
Route::post('/auth-remote-logout','\LaraDevs\AuthRemote\ActionsController@logout')->name('laravel_passport.logout');

Route::get('/', function () {
    return view('welcome');
})->name(config('rest-provider.route_not_session'));
bash
php artisan vendor:publish --provider="LaraDevs\AuthRemote\MainServiceProvider"