This is a minimal GNAP client in PHP to demonstrate interacting with a GNAP Authorization Server.
This is tested against the Java GNAP Server hosted at https://gnap-as.herokuapp.com/
Install PHP dependencies:
sudo apt install php8.1 php8.1-mbstring php8.1-curl redis-serverInstall the required libraries:
composer require phpseclib/phpseclib:~3.0
composer require web-token/jwt-key-mgmt web-token/jwt-signature
composer require predis/predisor just
composer installGenerate a private key:
php gnap-cli.php keygenThis will generate an RSA private key and save it in a file private.pem, and the corresponding public key in public.pem and the JWK public key in public-key.json.
Start a new request:
php gnap-cli.php startIf everything works, you should see a URL printed in the console. Open that URL in your browser to authorize the client.
Poll the transaction endpoint until the client gets a token:
php gnap-cli.php pollAfter you authorize the client, you should get an access token in the response!