Skip to content

Access denied when access token is changes #248

Open
@jerrykan

Description

@jerrykan

After changing the access token for our GitLab repositories I noticed a bunch of errors like the following in our logs:

Mar 27 20:15:45 sourcebota sourcebot[3821823]: [backend] | 2025-03-27T09:15:45.532Z info: [main] Fetching <redacted.gitlab.host>/<repo>...
Mar 27 20:15:45 sourcebota sourcebot[3821823]: [backend] | 2025-03-27T09:15:45.861Z error: [main] remote: HTTP Basic: Access denied. If a password was provided for Git authentication, the password was incorrect or you're required to use a token instead of a password. If a token was provided, it was either incorrect, expired, or improperly scoped. See https://gitlab.dpipwe.tas.gov.au/help/topics/git/troubleshooting_git.md#error-on-git-fetch-http-basic-access-denied
Mar 27 20:15:45 sourcebota sourcebot[3821823]: [backend] | fatal: Authentication failed for '<redacted.gitlab.host>/<repo>'

Looking in the git config files of the locally cached repositories it seems the "origin" remote url still contains the old access token, ie:

...
[remote "origin"]
        url = https://oauth2:<old access token>@<redacted.gitlab.host>/<repo>.git
        fetch = +refs/heads/*:refs/heads/*
...

It seems as though the remotes are not being updated with the new access token when it is changed in the Sourcebot configuration, which then seems to cause problems when trying to sync repositories with existing local caches.

As an aside I suspect #60 is a related problem (though it that case there is no access token to start with, so it results in a slightly different error).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions