I'm working on an OAuth Server in PHP. Currently using PHP Library http://bshaffer.github.io/oauth2-server-php-docs/
for it. Till now everything has been clear. Just want to know how to create the unique token for Client Id & Client Secret in PHP.
Now, I'm using the following piece of code for creating Client Id & Client Secret token.
$token = bin2hex(random_bytes($length));
But, a little bit confuses. whether, Is it a right way to do this thing or not? I also searched for any library to do this. But, didn't get one.
For PHP 5 >= 5.3.0, PHP 7
Use openssl_random_pseudo_bytes
$client_secret = bin2hex(openssl_random_pseudo_bytes(32));
There is also an article about OAuth 2.0 Client SecretID The Client ID and Secret
For PHP 7 Use random_bytes
$client_secret = bin2hex(random_bytes(32));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With