A very simple demo of OAuth 2.0 using Node.js,to add GitHub login to your app and access GitHub API.
Register the app on Github : https://github.com/settings/applications/new .
- "Application name" field, enter any name you like.
- "Homepage URL" field, enter "http://localhost:8080/ ".
- "callback URL" field, enter "http://localhost:8080/oauth/redirect ".
Once register, you will get a client ID and a client secret.
First, clone the repo.
$ git clone https://github.com/json-HB/githun-oauth-login.git
$ cd node-oauth-demo
Second, modify the config.
index.js
: replace the values of theclientID
andclientSecret
variables.public/index.html
: replace the values of theclient_id
variable.
Third, install the dependencies.
$ npm install
Now, run the server.
$ node index.js
Visit http://localhost:8080 in your browser, and click the link to login GitHub.