Search code examples
node.jsgitlabgitlab-api

GitLab API is returning random unrelated projects


I am trying to return a list of my Gitlab projects. Here is my API call:

const url = 'https://gitlab.com/api/v4/projects?private_token=MYPrivateToken'
request(url, function (error, response, body) {
    res.send(body)
});

For some reason I am just receiving a random list of projects from unrelated users that I have never heard of.

Any idea what is going on? I feel like I’m missing something obvious, can anyone at least confirm that it looks like it should be right?

I tried using the gitlab beaker project as well with the same results (random projects) and opened up this issue: https://github.com/jdalrymple/gitbeaker/issues/923 Here is my github project I created so gitbeaker maintainers could recreate the issue: https://github.com/JaredDahlke/gitlabTest/blob/master/README.md

I have been able to succesfully use 3rd party apps that access my projects such as Gitlab Notifier, which tells me my gitlab settings/access tokens should be working: https://chrome.google.com/webstore/detail/gitlab-notifier-for-googl/eageapgbnjicdjjihgclpclilenjbobi?hl=en


Solution

  • You have missed the query parameter owned in the url.

    Following should be the url to fetch projects owned by you.

    https://gitlab.com/api/v4/projects?private_token=MYPrivateToken&owned=yes

    For more info go through following url https://docs.gitlab.com/ee/api/projects.html