GithubHelp home page GithubHelp logo

nvdnkpr / oauth2orize-example-extended Goto Github PK

View Code? Open in Web Editor NEW

This project forked from angelsanchez/oauth2orize-example-extended

0.0 1.0 0.0 75 KB

Full oauth2rize example with 2 applications: oAuth2 provider and the client consumer

License: MIT License

oauth2orize-example-extended's Introduction

oauth2orize-example-extended

Full oauth2orize example with 2 applications:

  • server: oAuth2 service provider
  • client: oAuth2 client consumer

To execute the example:

  • Install all nodejs modules: npm install on /server and /client

  • Run the server (localhost:3000):

cd server
node app.js
  • Run the client (localhost:8080):
cd client
node app.js
  • Open a web browser and visit: http://localhost:8080/login and the oAuth2 flow will start. First the user log in the oAuth2 server, after must allow the consumer application's grants.

There are two services that consume protected services:

  • Returns basic user information: http://localhost:8080/userinfo
{
  "provider": "appexample",
  "id": "1",
  "name": "Bob Smith",
  "accessToken": "YhsKDUxkYDvrcgcPvtjeHnEjjmpzQPvz88oUtRdF13kx9IoC64j5buIJXoUELuewAc8eD0Q3fiBiufmLbj8KNFc1PR9dv3EFJcgRUPMuTrepddhvmOmeAHjDDtSLvbF04550rJ5AuOJDM6Yaqz2a3Ya0w32dZYOxww11peTQ3KooqpjRnXpzICQG25V428QQORwQwZkzmUxOcgR5TyylXUVSUhS36mhpyKEIEavCRdtc2bSBxCNijzOEU7c2e1cR"
}
  • Returns all user personal data: http://localhost:8080/personaldata
{"id":"1","username":"bob","password":"secret","name":"Bob Smith","phoneNumber":"785-873-3930","email":"[email protected]","address":"968 Sherman Street, Everest","birthday":"02-02-1992"}

You can change the scopes in client/app.js:

app.get('/auth/appexample',
  passport.authenticate('appexample', { scope: 'userinfo personaldata' }),
  function(req, res){
    console.log("Authorizating...")
  }
);

oauth2orize-example-extended's People

Contributors

jonasdacruz avatar

Watchers

 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.