Search code examples
node.jspostgithubissue-tracking

Node.js, create a github issue on a private repo


I have a private github repo that I would like to track issues for my app on. Github's API describes how to create an issue through a POST request. My question is, does this only work for public repositories? Am I overlooking a simple solution for allowing my application to create issues? I have tried the code below, however had no luck. Thanks!

var request = require('request');

var bugReport = 

{
  "title": "Found a bug",
  "body": "I'm having a problem with this.",
  "labels": [
    "bug"
  ]
}

request.post(
    'https://api.github.com/repos/...(username).../...(repo).../issues',
    { json: bugReport },
    function (error, response, body) {
        if (!error && response.statusCode == 200) {
            console.log(body)
        }
    }
);

Solution

  • You need to use an OAuth token with the right scope to authenticate before you can post to a private repo. See https://developer.github.com/apps/building-oauth-apps/authorizing-oauth-apps/