A minimal example of implementing Discourse User API keys in PHP.
Discourse redirects the user back with an encrypted payload, which will be encrypted with your keypair public key. To generate a keypair run the following OpenSSL command:
openssl genrsa -out keypair.pem 2048