NARKOZ / gitlab

Ruby wrapper and CLI for the GitLab REST API
https://narkoz.github.io/gitlab
BSD 2-Clause "Simplified" License
1.06k stars 395 forks source link

Projects are not scoped on my user / using global Gitlab scope instead #387

Closed bmedici closed 6 years ago

bmedici commented 6 years ago

Hello,

I have a strange behaviour with this gem, when authenticating with my own key:

client = Gitlab.client(endpoint: 'https://gitlab.com/api/v4/', private_token: "XYZT" )
client.projects.collect(&:name)

returns random projects that are not mine at all:

=> ["rotwk202-source", "gitlab_taiga_integration", "TekSavvyProject", "TestProject", "acquire-frontend-exam", "gcp-is-awesome", "hello_prakash", "haskell-exercises", "webmail", "file2c", "node-js-sample1", "ZawayaLLC", "yara-system", "yara-project", "node-js-sample", "test", "GitLab CI Yml", "ewa", "digits", "Sis.Esc.BD"]

What could be the cause for his ? How should I request all my projects or better, all my projects for a given Gitlab group ? Thank you for your help !

asedge commented 6 years ago

Look at the method documentation for #projects, you can specify a :scope here. This should limit it to a specific group. The API docs spell it out pretty simply:

Get a list of all visible projects across GitLab for the authenticated user.

The other options specified in the API docs can be passed as part of an options Hash, which is the (optional) last argument of the #projects method call.