gitlab-finder
gitlab-finder copied to clipboard
Always runs into HTTPError: Response code 401
Hi there 👋🏼
I followed the README but somehow my token is always shown as invalid.
I tried with other libraries to make requests to the API and the token is considered valid there. Don't know what I'm missing here? Any ideas? Is the underlaying library broken (gitbeaker)?
➜ gitlab-finder ~/gitlab-finder git:(master) ✗ yarn search
yarn run v1.22.19
warning ../../../package.json: No license field
$ node src/search.js
node:internal/process/promises:289
triggerUncaughtException(err, true /* fromPromise */);
^
HTTPError: Response code 401 (Unauthorized)
at Request.<anonymous> (/gitlab-finder/node_modules/got/dist/source/as-promise/index.js:118:42)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 'ERR_NON_2XX_3XX_RESPONSE',
timings: {
start: 1720005885242,
socket: 1720005885243,
lookup: 1720005885254,
connect: 1720005885267,
secureConnect: 1720005885278,
upload: 1720005885278,
response: 1720005885441,
end: 1720005885443,
error: undefined,
abort: undefined,
phases: {
wait: 1,
dns: 11,
tcp: 13,
tls: 11,
request: 0,
firstByte: 163,
download: 2,
total: 201
}
},
description: 'invalid_token'
}
Node.js v20.12.1
For me it works fine. Maybe you added the wrong gitlab host in the .env? @bytehead
ok, a little hope at least :) but no, the gitlab host seems to be correct, https://gitlab.com.
Hi @bytehead To replicate your issue, I just set in my .env a wrong personnal token Maybe you just have to generate a new one https://gitlab.com/-/user_settings/personal_access_tokens
I also run into some several minor bug so I just push an update to upgrade the GitBeaker library
I'm gonna try it again 🙃
I don't get it 😅
Just regenerated a token (even) with api scope - still getting GitbeakerRequestError: Unauthorized.
Any ideas to debug?
@bytehead another dependencies update, but I still have no clue about your error and how to replicate it.
I created an account on https://gitlab.com/ and even there it works for me with a new generated token.
@nis267 With an organization?
# Group ID to search in
# default search in all groups
GROUP_ID=
In my case it gives me this GitbeakerRequestError: Unauthorized error in both cases, with a GROUP_ID and without. 😞
My env looks like this with my token hidden with x's
GITLAB_HOST=https://gitlab.com GITLAB_TOKEN=glpat-xxxxxxxxxxxxxxxxxxx SEARCH_DELAY=6000 SEARCH_FILE_PATTERN=* SEARCH_KEYWORD=test GROUP_ID=
And are you sure that you don't have gitlab self hosted? Then the host is different than https://gitlab.com
here is my .env:
GITLAB_HOST=https://gitlab.com
GITLAB_TOKEN=glpat-xxx
# pause time in ms between search api call (6000 is recommanded on official Gitlab instance)
SEARCH_DELAY=6000
# File pattern filter (eg. *.php)
SEARCH_FILE_PATTERN=*
# string to find
SEARCH_KEYWORD=test
# Group ID to search in
# default search in all groups
GROUP_ID=