Skip to content

Commit

Permalink
All user to set GitHub PAT
Browse files Browse the repository at this point in the history
A key is needed to search GitHub and to get the users email address. #15
  • Loading branch information
rkotze committed Sep 4, 2020
1 parent 011a815 commit 6b9a516
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@
"type": "boolean",
"default": true,
"description": "Expand 'More Authors' tree when UI starts"
},
"gitMob.gitHub.personalAccessToken": {
"type": "string",
"default": "",
"description": "GitHub personal access token (read:user) https://github.com/settings/tokens"
}
}
},
Expand Down
8 changes: 7 additions & 1 deletion src/github/github-api.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
const vscode = require("vscode");
const { fetch } = require("./fetch");

const GITHUB_API = "https://api.github.com/";

async function get(path) {
const gitHubSettings = vscode.workspace.getConfiguration("gitMob.gitHub");
const pat = gitHubSettings.get("personalAccessToken");
if (!pat) {
throw new Error("No GitHub personal access token found");
}
try {
const result = await fetch(GITHUB_API + path, {
method: "GET",
headers: {
Accept: "application/vnd.github.v3+json",
Authorization: "token <tokenhere>",
Authorization: `token ${pat}`,
},
});

Expand Down

0 comments on commit 6b9a516

Please sign in to comment.