jonas-thuvesson-winberg / logrocket-oauth2-example

Implementing OAuth 2.0 in Node.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Implementing OAuth 2.0 in Node.js

This is the source code for my article on Implementing OAuth 2.0 in Node.js.

Before running the app, you have to set up the Postgres database. For this, install Postgres and create a new database called logrocket_oauth2.

Then, run this script to create the tables:

CREATE TABLE public.users
(
    id serial,
    username text,
    user_password text,
    PRIMARY KEY (id)
)
WITH (
    OIDS = FALSE
);

ALTER TABLE public.users
    OWNER to postgres;



CREATE TABLE public.access_tokens
(
    id serial,
    access_token text,
    user_id integer,
    PRIMARY KEY (id)
)
WITH (
    OIDS = FALSE
);

ALTER TABLE public.access_tokens
    OWNER to postgres;

After that, run the command to install the npm dependencies:

npm install

And finally:

node index.js

The app will start at http://localhost:3000.

About

Implementing OAuth 2.0 in Node.js


Languages

Language:JavaScript 100.0%