PHP code example of diimolabs / laravel-oauth2-client

1. Go to this page and download the library: Download diimolabs/laravel-oauth2-client 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/ */

    

diimolabs / laravel-oauth2-client example snippets


    protected $routeMiddleware = [
        // Other middleware...
        'jwt' => \Diimolabs\OAuth\Middleware\EnsureJwtIsValid::class
    ];
    

use Diimolabs\OAuth\Facades\OAuthClient;
use Illuminate\Support\Facades\Route;

Route::prefix('v1')->group(function(){
    Route::get('message', function(){
        return OAuthClient::request()
            ->get('http://msa-2.test/api/v1/hello-world')
            ->body();
    });
});


use Illuminate\Support\Facades\Route;

Route::prefix('v1')->middleware('jwt')->group(function ()
{
    Route::get('/hello-world', function ()
    {
        return 'Hello world from microservice 2';
    });
});

php artisan vendor:publish --tag=oauth-client