Issue authenticating app / permissions using octokit

Hi Support,

It seems like a very simple problem, but not sure where I am going wrong. I’m trying to use octokit to add a commit to a specific repository. The code is:

const { createAppAuth } = require('@octokit/auth-app');

    // get authentication
    const auth = createAppAuth({
      id: '******',
      privateKey: PRIVATE_KEY,
      installationId: 456,
      clientId: '******',
      clientSecret: '******',
    });

    console.log(auth);

    const { request } = require('@octokit/request');

    // use authentication to do stuff.
    const requestWithAuth = request.defaults({
      request: {
        hook: auth.hook,
      },
      mediaType: {
        previews: ['machine-man'],
      },
    });

    console.log(requestWithAuth);

    const result1 = await requestWithAuth('GET /app');

    console.log(result1);

    const result = await requestWithAuth('GET /repos/:owner/:repo', {
      owner: 'q6a',
      repo: 'q6a.source',
    });

    console.log(result);

As far as I can tell, I am authenticating properly. However:

  • The GET /app seems to work fine. Have highlighted it seems to work.
  • The GET /repos/:owner/:repo fails
  • What is the InstallationId supposed to be - is this the issue?

Any ideas what I am doing wrong? The idea is to do a commit into this specific repo.

Thanks very much guys!

The repo is private, but I have installed the app and given it the correct permissions.

Permissions - Have given it read rights to admin (for the repos) and read + write to content so i can do the commit.

Apols about breaking up the comment, apparently I can only do one image at a time.

Thanks so much.

Tat