##Sehati API
##REST API with OAuth
Route | HTTP | Description |
---|---|---|
/login | GET | Print: Login page |
/login/local | GET | Print: Login |
/login/local | POST | req.body (username & password) |
/login/exit | GET | Print: Logout |
Route | HTTP | Description |
---|---|---|
/login/facebook | GET | Print: Login page on FB |
/login/facebook/callback | GET | Print: Callback |
/login/facebook | POST | Print: Page on FB |
/login/facebook/exit | GET | Print: Logout |
Route | HTTP | Description |
---|---|---|
/login/twitter | GET | Print: Login page on Twitter |
/login/twitter/callback | GET | Print: Callback |
/login/twitter | POST | Print: Page on Twitter |
/login/twitter/exit | GET | Print: Logout |
Route | HTTP | Description |
---|---|---|
/login/google | GET | Print: Login page on Google |
/login/google/callback | GET | Print: Callback |
/login/google | POST | Print: Page on Google |
/login/google/exit | GET | Print: Logout |
npm init
npm install express
npm install nodemon
npm run dev
npm install jsonwebtoken
npm install password-hash
npm install --save dotenv
npm install mongoose
npm install passport passport-local
npm install passport-facebook
npm install passport-twitter
npm install express-session
npm install passport-google-oauth20
sudo service mongod start
connection @robomongo
mongo
use user
create file connection: db.js
Using passport local: //Must first position in app.use app.use(passport.initialize());
Correct Structure:
- passport.session
- cookieParser
- session
- app.router
P.s. Token will get when sign in as Admin
Access the website via http://localhost:3000 or API via http://localhost:3000/login
Debugger encode & decode via https://jwt.io/