1. Go to this page and download the library: Download auth0/auth0-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/ */
auth0 / auth0-php example snippets
use Auth0\SDK\Auth0;
use Auth0\SDK\Configuration\SdkConfiguration;
$configuration = new SdkConfiguration(
domain: 'Your Auth0 domain',
clientId: 'Your Auth0 application client ID',
clientSecret: 'Your Auth0 application client secret',
cookieSecret: 'Your generated string',
);
$auth0 = new Auth0($configuration);
// getCredentials() returns null if the user is not authenticated.
$session = $auth0->getCredentials();
if (null === $session || $session->accessTokenExpired) {
// Redirect to Auth0 to authenticate the user.
header('Location: ' . $auth0->login());
exit;
}
if (null !== $auth0->getExchangeParameters()) {
$auth0->exchange();
}
print_r($auth0->getCredentials()?->user);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.