0

I have been trying to set up a simple Github App using octokit

The below code shows two approaches that I tried as per the docs. The first approach works, the latter fails with:

401 HttpError: Missing 'issuer' claim ('iss') in assertion

At this point it is mostly a curiosity but I would like to understand what the difference between the two instances is.

const { Octokit, App } = require("octokit");
const { createAppAuth } = require("@octokit/auth-app");

require("dotenv").config();

async function main() {
  // This works
  const app = new App({
    appId: process.env.GITHUB_APP_ID,
    privateKey: process.env.GITHUB_APP_PRIVATE_KEY,
  });

  const octokit = await app.getInstallationOctokit(
    process.env.GITHUB_APP_INSTALLATION_ID
  );

  const {
    data,
  } = await octokit.rest.apps.getAuthenticated();

  // This doesn't work!
  const octokit2 = new Octokit({
    authStrategy: createAppAuth,
    auth: {
      appId: process.env.GITHUB_APP_ID,
      privateKey: process.env.GITHUB_APP_PRIVATE_KEY,
      installationId: process.env.GITHUB_APP_INSTALLATION_ID,
    },
  });
  
  const {
    data2,
  } = await octokit2.rest.apps.getAuthenticated();
}

main();

1 Answers1

0

You can try this:

import { Octokit } from '@octokit/rest';
sadeq shahmoradi
  • 1,395
  • 1
  • 6
  • 22
  • Answer needs supporting information Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](https://stackoverflow.com/help/how-to-answer). – moken Jul 01 '23 at 09:23