1. Go to this page and download the library: Download kdoyen/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/ */
kdoyen / openid-connect-php example snippets
use OpenIdConnectClient\OpenIdConnectClient;
$oidc = new OpenIDConnectClient([
'provider_url' => 'https://id.provider.com/',
'client_id' => 'ClientIDHere',
'client_secret' => 'ClientSecretHere'
]);
$oidc->authenticate();
$name = $oidc->requestUserInfo('given_name');
use OpenIdConnectClient\OpenIdConnectClient;
$oidc = new OpenIDConnectClient([
'provider_url' => 'https://id.provider.com/'
]);
$oidc->register();
$client_id = $oidc->getClientID();
$client_secret = $oidc->getClientSecret();
// Configure a proxy
$oidc->setHttpProxy('http://my.proxy.com:80/');
// Configure a cert
$oidc->setCertPath('/path/to/my.cert');
use OpenIdConnectClient\OpenIdConnectClient;
$oidc = new OpenIDConnectClient([
'provider_url' => 'https://id.provider.com/',
'client_id' => 'ClientIDHere',
'client_secret' => 'ClientSecretHere'
]);
$oidc->providerConfigParam([
'token_endpoint' => 'https://id.provider.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 OpenIdConnectClient\OpenIdConnectClient;
$oidc = new OpenIDConnectClient([
'provider_url' => 'https://id.provider.com/',
'client_id' => 'ClientIDHere',
'client_secret' => 'ClientSecretHere'
]);
// Provide access token to introspect.
// Can take an optional second parameter to set the token_type_hint.
$introspectionResponse = $oidc->introspectToken('provided_access_token');
// Check if the response/token is active and valid (based on exp and nbf).
$introspectionResponse->isActive();
// Get a list of allowed scopes.
$scopeArray = $introspectionResponse->getScopes();
// Simple boolean response if response has scope provided.
$introspectionResponse->hasScope('profile');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.