PHP code example of b2pweb / parroauth2-client
1. Go to this page and download the library: Download b2pweb/parroauth2-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/ */
b2pweb / parroauth2-client example snippets
$loader = new \Parroauth2\Client\Provider\ProviderLoader();
// Configure and create the provider
$provider = $loader->builder('http://my-op.example.com')
->openid() // Enable openid connection on the endpoint
// Configure endpoints
->tokenEndPoint('/token')
->authorizationEndPoint('/auth')
->introspectionEndPoint('/introspect')
// Configure public key for local introspection
->addKeyFile('./keys/provider.pub')
->create()
;
// Create the client
$client = $provider->client((new \Parroauth2\Client\ClientConfig('client_id'))->setSecret('secret'));
/** @var $client \Parroauth2\Client\ClientInterface */
$token = $client->endPoints()->token();
$token->refresh('MyRefreshToken'); // This instruction has no effect : the return value is ignored
$token->call(); // This call will fail : no token has been provided