PHP code example of softonic / guzzle-oauth2-middleware
1. Go to this page and download the library: Download softonic/guzzle-oauth2-middleware 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/ */
softonic / guzzle-oauth2-middleware example snippets
php
$options = [
'clientId' => 'myclient',
'clientSecret' => 'mysecret'
];
// Any provider extending League\OAuth2\Client\Provider\AbstractProvider will do
$provider = new Softonic\OAuth2\Client\Provider\Softonic($options);
// Send OAuth2 parameters and use token_options for any other parameters your OAuth2 provider needs
$config = ['grant_type' => 'client_credentials', 'scope' => 'myscope', 'token_options' => ['audience' => 'test_audience']];
// Any implementation of PSR-6 Cache will do
$cache = new \Symfony\Component\Cache\Adapter\FilesystemAdapter();
$client = \Softonic\OAuth2\Guzzle\Middleware\ClientBuilder::build(
$provider,
$config,
$cache,
['base_uri' => 'https://foo.bar/']
);
$response = $client->request('POST', 'qux);