Complete Symfony3 REST Skeleton w/ FOSRESTBundle, FOSUserBundle, FOSOAuthBundle Pre-Installed.
git clone <RepoURL> <ProjectName>
composer install
php bin/console doctrine:database:create
php bin/console doctrine:schema:update --force
Only use the grant-type you intend to use.
php bin/console acme:oauth-server:client:create --redirect-uri="http://127.0.0.1:8000/" --grant-type="authorization_code" --grant-type="password" --grant-type="refresh_token" --grant-type="token" --grant-type="client_credentials"
curl -X POST -H "Content-Type: application/json" -H "Accept: application/json" -d '{"user":{"username": "zac", "password": "1qaz", "email": "[email protected]"}}' http://127.0.0.1:8000/app_dev.php/users
Browse to the following URL while Replacing CLIENTID, CLIENTSECRET, USERNAME, & PASSWORD with your values:
http://127.0.0.1:8000/app_dev.php/oauth/v2/token?client_id=__CLIENTID__&client_secret=__CLIENTSECRET__&grant_type=password&username=USERNAME&password=PASSWORD
The following will return a access_denied error:
curl http://127.0.0.1:8000/app_dev.php/users
The following will return successful set of users (json).
curl -H "Authorization: Bearer ACCESS_TOKEN" -H "Accept: application/json" http://127.0.0.1:8000/app_dev.php/users
To return JSON set Accept Header to application/json. Will return an HTML view by default. Does not return XML. To return XML check the FOSRESTBundle docs and set in config.yml.
- Unit Testing