1. Go to this page and download the library: Download authwave/php-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/ */
authwave / php-client example snippets
use Authwave\Authenticator;
rom your application's configuration
// or environment variables. It is created in the remote Authwave provider.
define("CLIENT_KEY", "1234567890abcdef");
// Construct the Authenticator class as soon as possible, as this handles the
// Authentication steps passed via the query string from the remote provider.
$auth = new Authenticator(
CLIENT_KEY,
$_SERVER["REQUEST_URI"],
);
// Handle authentication login/logout action via the querystring:
if(isset($_GET["login"])) {
// This will redirect the user agent to the auth uri, which is a location on the
// remote provider. The remote provider will in turn redirect the user agent
// back to the return URI (set as 3rd parameter of Authenticator's constructor),
// at which point the user will be considered authenticated.
$auth->login();
}
elseif(isset($_GET["logout"])) {
$auth->logout();
}
// Authentication is handled by Authwave, so you can trust "isLoggedIn"
// as a mechanism for protecting your sensitive information.
if($auth->isLoggedIn()) {
// Available methods:
// $auth->getId(); // a unique string in ULID format - use this to store in your database
// $auth->getEmail(); // the current email of the user (could change)
// $auth->getField($name); // any extra field your application is configured to take upon user signup
echo <<<HTML
<p>You are logged in as <strong>{$auth->getEmail()}</strong></p>
<p><a href="?logout">Log out</a></p>
HTML;
}
else {
echo <<<HTML
<p>You are not logged in!</p>
<p><a href="?login">Log in</a></p>
HTML;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.