Skip to content

Commit 4db7cb2

Browse files
committed
feat: token api
1 parent cf767dc commit 4db7cb2

File tree

4 files changed

+37
-0
lines changed

4 files changed

+37
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/

api/token.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import fetch from "node-fetch";
2+
3+
export default async (req, res) => {
4+
const r = await fetch("https://github.com/login/oauth/access_token", {
5+
method: "POST",
6+
headers: {
7+
"Content-Type": "application/json"
8+
},
9+
body: JSON.stringify({
10+
...req.body,
11+
client_secret: process.env.CLIENT_SECRET
12+
})
13+
});
14+
const json = await r.json();
15+
res.json(json);
16+
};

now.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"env": {
3+
"CLIENT_SECRET": "@client_secret"
4+
}
5+
}

package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "github-oauth-api",
3+
"version": "0.0.1",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"keywords": [],
10+
"author": "Rongjian Zhang <pd4d10@gmail.com>",
11+
"license": "MIT",
12+
"dependencies": {
13+
"node-fetch": "^2.6.0"
14+
}
15+
}

0 commit comments

Comments
 (0)