Skip to content

Instantly share code, notes, and snippets.

@kevinsimper
Created March 26, 2020 16:29
Show Gist options
  • Save kevinsimper/c00b5882e1830614d9242007fa9bee5e to your computer and use it in GitHub Desktop.
Save kevinsimper/c00b5882e1830614d9242007fa9bee5e to your computer and use it in GitHub Desktop.
commit 4efbae971b6d4f5aeeb876307657c86545f8948b
Author: Kevin Simper <kevin.simper@gmail.com>
Date: Thu Mar 26 17:26:43 2020 +0100
Article spelled client_id wrong
diff --git a/server.js b/server.js
index c3b2928..b7980ac 100644
--- a/server.js
+++ b/server.js
@@ -4,17 +4,17 @@ import fetch from 'node-fetch'
const app = express()
-async function getAccessToken({ code, client, client_secret }) {
console.log(code)
console.log(client)
console.log(client_secret)
+async function getAccessToken({ code, client_id, client_secret }) {
const request = await fetch('https://github.com/login/oauth/access_token', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
- client,
+ client_id,
client_secret,
code
})
@@ -48,11 +48,11 @@ app.get('/login/github', (req, res) => {
)
})
-const client = process.env.GITHUB_CLIENT_ID
+const client_id = process.env.GITHUB_CLIENT_ID
const client_secret = process.env.GITHUB_CLIENT_SECRET
app.get('/login/github/callback', (req, res) => {
const code = req.query.code
- const access_token = getAccessToken({ code, client, client_secret })
+ const access_token = getAccessToken({ code, client_id, client_secret })
const user = fetchGitHubUser(access_token)
console.log(user.id)
if (user.id === 1126497) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment