PHP code example of adriengras / pkce-php
1. Go to this page and download the library: Download adriengras/pkce-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/ */
adriengras / pkce-php example snippets
// import with composer autoloader
use AdrienGras\PKCE\PKCE;
// ...
// generate a code verifier
$verifier = PKCEUtils::generateCodeVerifier();
// generate a code challenge from the code verifier
$challenge = PKCEUtils::generateCodeChallenge($verifier);
// you can also use the plain text challenge method for testing purpose
// WARNING: this method is not secure and should not be used in production
$challenge = PKCEUtils::generateCodeChallenge($verifier, PKCEUtils::CODE_CHALLENGE_METHOD_PLAIN);
// alternatively, generate a pair of code verifier and code challenge
$pair = PKCEUtils::generateCodePair();
$verifier = $pair['code_verifier'];
$challenge = $pair['code_challenge'];
// or with destructuring
[$verifier, $challenge] = PKCEUtils::generateCodePair();
// validate a code verifier with a code challenge
$isValid = PKCEUtils::validate($verifier, $challenge);
bash
composer