Hi I am trying to fetch all the repos (including private ones) including their PRs and Reviews. I am authenticating using my personal access token that has SSO enabled for the organization whose repos I want to fetch. But for some reason it only works for public repos and I dont see any private repos in my results
Here is the code
ctx := context.Background()
ts := oauth2.StaticTokenSource(
&oauth2.Token{AccessToken: "my-token"},
)
tc := oauth2.NewClient(ctx, ts)
client := github.NewClient(tc)
prs, _, err := client.PullRequests.List(ctx, "org-name", "private-repo-name", nil)
checkErr(err)
for _, pr := range prs {
fmt.Println(*pr.Title)
}
I get an error saying GET https://api.github.com/repos/org-name/private-repo-name/pulls: 404 Not Found [] if I try to fetch the PRs of a private repo from that org
If however, I try a public repo it works.
I am able to access these repos on github
Am I authenticating my client correctly?
cc @gmlewis
Your code above works fine on my private repo.
So I'm assuming that from your account (where you got your personal access token), you can see the private repo.
I'm also assuming that your personal access token has full repo rights, which are required to see private repos.
If either of those statements are not true, your code above will not work.
Good luck.
Here is a screenshot of the scopes that my personal access token has, hoping that will help you:

Also, this may be obvious, but in order to be thorough, I need to state that the private repo must have at least one PR in order to get more than an empty list in response to the API call. 馃榿
The private repo is actually under an organization not under my account. I did check all the boxes while creating the access token and then enabled SSO on that token for the org.
I am able to view the repo on GitHub and it does have PRs.
The next step to debug this is to call the v3 API directly using curl.
If you get results we can then try to figure out what is different between this repo and the curl version.
If you don't get expected results, then there is some other problem unrelated to this repo. As a last resort, you can then contact [email protected] and ask for their assistance.
Tried a curl request got a 404 again
OK, thank you for reporting back, @palash25 (and for closing).
Good luck fixing the problem!
(I'm not sure if you are using an Enterprise version of GitHub, but sometimes we have seen some odd differences in the way they operate, presumably because of the settings the particular organization chose to set when running their instance... or simply due to the (older) version they are using. That might be something you want to investigate.)