Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to list private repositories #369

Open
deanwilson opened this issue Jul 14, 2020 · 3 comments
Open

Unable to list private repositories #369

deanwilson opened this issue Jul 14, 2020 · 3 comments

Comments

@deanwilson
Copy link

deanwilson commented Jul 14, 2020

Hello, I'm unsure if this is user error (most likely) but I'm having issues including private repositories in the results of a repos.list call. I've tried using different scopes in the generated Personal access token, including adding one with all permissions enabled, but i am still unable to list private repositories.

require 'github_api'

username = 'deanwilson'
private_repo = 'private-test-repo_name'

config = {
  auto_pagination: true,
  oauth_token:     ENV['GITHUB_TOKEN'],
  user:            username
}

github = Github.new config

# get the private repo directly
foo = github.repos.get user: username, repo: private_repo

puts "Is #{private_repo} private? #{foo.private}"


# list _all_ repos
repos = github.repos.list
puts "Looking through #{repos.length} repos"

names = repos.map {|r| r.name }

if names.include? private_repo
  puts "Found private repo in list"
else
  puts "Didn't find private repo in list"
end

private_repos = repos.select {|r| r.private }
puts "Found #{private_repos.length} private repos"
__END__

bundle exec ruby lister
Is private-test-repo private? true
Looking through 87 repos
Didn't find private repo in list
Found 0 private repos

This is an individual github user but it is also assicatyed with a small number of orgs. I am only attempting to list the users own repos.

Any advice on this would be appreciated.

Thank you for your time.

@deanwilson
Copy link
Author

deanwilson commented Jul 14, 2020

If i change user: username to org: 'actual-org-name it does return private repositories that are present in the specified organisation.

@trucktank
Copy link

wadl20090202.pdf

@scalp42
Copy link

scalp42 commented Mar 14, 2021

Same thing for me, tried switching user to be org but same result still can't list private repositories.

I, [2021-03-13T20:03:19.585025 #18918]  INFO -- request: GET https://api.github.com/orgs/xxx/repos?type=private&per_page=50
I, [2021-03-13T20:03:19.585083 #18918]  INFO -- request: Accept: "application/vnd.github.v3+json,application/vnd.github.beta+json;q=0.5,application/json;q=0.1"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants