node.jsgithub-api-v3octokit-js

Octokit.js github base url setup


I am trying to authenticate with my enterprise github through App in octokit.js but I couldn't find any parameter to change gihub url. Can someone please help?

const {Octokit, App} = require('octokit')

// below points to github.com
const app = new App({ appId: appId1, privateKey: privateKey1 }) 

// below does not work
//const app = new App({ appId: appId1, privateKey: privateKey1 , baseUrl: mygitHub })

app.octokit.rest.apps.getAuthenticated();

Using nodejs.


Solution

  • Found answer at https://github.com/octokit/app.js/#constructor

    const { Octokit } = require("@octokit/core");
    new App({
      appId: 123,
      privateKey: "-----BEGIN PRIVATE KEY-----\n...",
      oauth: {
        clientId: 123,
        clientSecret: "secret",
      },
      webhooks: {
        secret: "secret",
      },
      Octokit: Octokit.defaults({
        baseUrl: "https://ghe.my-company.com/api/v3",
      }),
    });