Git Product home page Git Product logo

fosrest-user-oauth-skeleton's Introduction

FOSREST-User-OAuth-Skeleton

Complete Symfony3 REST Skeleton w/ FOSRESTBundle, FOSUserBundle, FOSOAuthBundle Pre-Installed.

Installation:

git clone <RepoURL> <ProjectName>
composer install
php bin/console doctrine:database:create
php bin/console doctrine:Schema:update --force

Create An OAuth Client

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"

Create A User

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

Get User Access & Refresh Tokens

Browse to the following URL while Rrplacing 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 

See Authorization Failure:

The following will return a access_denied error:

curl http://127.0.0.1:8000/app_dev.php/users

See Authorization Success:

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

PreConfigs:

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.

//TODO

  • Unit Testing

fosrest-user-oauth-skeleton's People

Contributors

mattwohler avatar zball avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.