strangeQuirks
strangeQuirks

Reputation: 5940

Get public AND private repositories of a user

I am trying to get public and private repos of a user.

So I authorize a user using this user to get the code:

https://github.com/login/oauth/authorize?scope=read:user,repo&client_id=${process.env.NEXT_PUBLIC_GITHUB_APP_CLIENT_ID}&redirect_uri=${redirectUrl}

I then get the token using the following:

const octokit = new Octokit({
    authStrategy: createOAuthAppAuth,
    auth: {
      clientId: process.env.NEXT_PUBLIC_GITHUB_APP_CLIENT_ID,
      clientSecret: process.env.GITHUB_APP_CLIENT_SECRET,
    },
  });
const result = await octokit.auth({
      type: 'oauth-user',
      code,
    });
const { token } = result as any;

Then I do the following to get repos of a user:

const responseRepos = await octokitUser.request('GET /user/repos', {
      headers: {
        'X-GitHub-Api-Version': API_VERSION,
        authorization: `Bearer ${token}`,
      },
    });

However it only returns public repos and not private. Anyone know whats wrong?

Upvotes: 0

Views: 42

Answers (0)

Related Questions