List all repos(internal included) from a Github org using API

I am trying to list all the repos(public, internal) within the org that I am the owner of using the below command.

$orgRepos = Invoke-WebRequest -H $headers -Uri "{$orgName}/repos"

There are about 2 public repos and 10+ internal repos but the above command is listing out only the 2 public repos. I went through the documentation and tried all the options as suggested here with type and per_page but nothing seems to help. For headers, I created it using my PAT by giving access to all the permissions.

$headers = @{
      Authorization = "Basic $($token)"
      Accept = "application/vnd.github.v3+json"

How do I get to list out the internal repositories?

Are you using GHEC or GHES?

We use GHEC. Thanks!

I can’t recreate this. When I run the same command against my GHEC, it is returning all the repos. Interesting, it shows internal as private, but otherwise it is returning all the repos.

Check your PAT. Does it have the appropriate rights? Can you create a token with all rights, just to make sure? Are you using SSO? Did you click the enable sso on your PAT?

Thanks for looking into this. Just for confirmation, you had run the same command that I had listed above and its listing out all the internal repos as well?

Yes, as for the PAT, I went ahead and created one with all the permissions but am still not able to see the internal repos. One of the other team members with similar admin permissions is seeing the same issue as well. We use SSO and enabled it for the PAT too.


oh wait. My curl command is slightly differnet :slight_smile:

If I use “basic”, I don’t get back my internal ones.

However, if I use Token, I do:

curl -H ‘Authorization: token your-token-here’ ‘ org here/repos’

In your header, replace “Basic” with “token” and see what happens.

1 Like

Awesome, that worked, thanks! would be great if the documentation covers this as well :slight_smile: thanks for your time again!