1. Go to this page and download the library: Download juliuspc/openid-connect-php 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/ */
juliuspc / openid-connect-php example snippets
use JuliusPC\OpenIDConnect\Client;
$oidc = new Client('https://id.example.com',
'ClientIDHere',
'ClientSecretHere');
$oidc->authenticate();
$name = $oidc->requestUserInfo('given_name');
use JuliusPC\OpenIDConnect\Client;
$oidc = new Client("https://id.example.com");
$oidc->register();
$client_id = $oidc->getClientID();
$client_secret = $oidc->getClientSecret();
// Be sure to add logic to store the client id and client secret
// Configure a proxy
$oidc->setHttpProxy("http://my.proxy.example.net:80/");
// Configure a cert
// If we omit this, the OS’ default cert bundle will be used
$oidc->setCertPath("/path/to/my.cert");
use JuliusPC\OpenIDConnect\Client;
$oidc = new Client('https://id.example.com',
'ClientIDHere',
'ClientSecretHere');
$oidc->providerConfigParam(array('token_endpoint'=>'https://id.example.com/connect/token'));
$oidc->addScope('my_scope');
// this assumes success (to validate check if the access_token property is there and a valid JWT) :
$clientCredentialsToken = $oidc->requestClientCredentialsToken()->access_token;
use JuliusPC\OpenIDConnect\Client;
$oidc = new Client('https://id.example.com',
'ClientIDHere',
'ClientSecretHere');
$oidc->setResponseTypes(array('id_token'));
$oidc->addScope(array('openid'));
$oidc->setAllowImplicitFlow(true);
$oidc->addAuthParam(array('response_mode' => 'form_post'));
$oidc->authenticate();
$sub = $oidc->getVerifiedClaims('sub');
use JuliusPC\OpenIDConnect\Client;
$oidc = new Client('https://id.example.com',
'ClientIDHere',
'ClientSecretHere');
$data = $oidc->introspectToken('an.access-token.as.given');
if (!$data->active) {
// the token is no longer usable
}
use JuliusPC\OpenIDConnect\Client;
$oidc = new Client('https://id.example.com',
'ClientIDHere',
'ClientSecret'); // you may obmit the client secret
// for some reason we want to set S256 explicitly as Code Challenge Method
// maybe your OP doesn’t announce support for PKCE in its discovery document
$oidc->setCodeChallengeMethod('S256');
$oidc->authenticate();
$name = $oidc->requestUserInfo('given_name');
$oidc->setVerifyPeer(false);
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.