oauth2-server/examples
2016-02-22 03:00:50 -05:00
..
public Applied fixes from StyleCI 2016-02-22 03:00:50 -05:00
src Applied fixes from StyleCI 2016-02-19 18:09:39 -05:00
composer.json Require league/plates in the examples composer.json 2016-02-12 11:31:46 +00:00
composer.lock Require league/plates in the examples composer.json 2016-02-12 11:31:46 +00:00
README.md Updated examples 2016-01-13 00:28:52 +00:00

Example implementations

Installation

  1. Run composer install --no-dev in this directory to install dependencies
  2. Create a private key openssl genrsa -out private.key 1024
  3. Create a public key openssl rsa -in private.key -pubout > public.key
  4. cd into the public directory
  5. Start a PHP server php -S localhost:4444

Testing the client credentials grant example

Send the following cURL request:

curl -X "POST" "http://localhost:4444/client_credentials.php/access_token" \
	-H "Content-Type: application/x-www-form-urlencoded" \
	-H "Accept: 1.0" \
	--data-urlencode "client_id=myawesomeapp" \
	--data-urlencode "scope=basic email" \
	--data-urlencode "client_secret=abc123" \
	--data-urlencode "grant_type=client_credentials"

Testing the password grant example

Send the following cURL request:

curl -X "POST" "http://localhost:4444/password.php/access_token" \
	-H "Content-Type: application/x-www-form-urlencoded" \
	-H "Accept: 1.0" \
	--data-urlencode "client_id=myawesomeapp" \
	--data-urlencode "scope=basic email" \
	--data-urlencode "username=alex" \
	--data-urlencode "password=whisky" \
	--data-urlencode "client_secret=abc123" \
	--data-urlencode "grant_type=password"

Testing the refresh token grant example

Send the following cURL request. Replace {{REFRESH_TOKEN}} with a refresh token from another grant above:

curl -X "POST" "http://localhost:4444/refresh_token.php/access_token" \
	-H "Content-Type: application/x-www-form-urlencoded" \
	-H "Accept: 1.0" \
	--data-urlencode "grant_type=refresh_token" \
	--data-urlencode "client_id=myawesomeapp" \
	--data-urlencode "client_secret=abc123" \
	--data-urlencode "refresh_token={{REFRESH_TOKEN}}"