Issues with access tokens and permissions

Since the last 3 or 4 feature versions released (currently on the latest version as of today)
I have problems with access token.

So I have enabled 2FA on my managed instance this does require access token to use to be able to pull push to the git server. However I always get authentication failed why I try to push to the remote.

My steps:

I create an access token in the project itself.
I set maintainer as role, I delete the expiration date 'which should default to 1 year).
I set permissions to ‘write repository’ which should give pull and push also described in the description.

Then I use this command to set it:

git remote set-url origin http://username:token@domain/username/repository

If i check the local .git folder in config file I get this.

When i pull from the main repository I get no errors and it seems successfull, however when i try to push a commit I get this error.

Screenshot 2024-11-22 143119

Normally, I always used this command and it worked always up until like a few feature versions back. I have no clue if this is because i’m missing a permission or something else.

EDIT:
I tried to troubleshoot some.
Event if I create a token with api permission which should be able for the project I get the same error.

After some chatgpt troubleshooting I tried this:

Invoke-WebRequest -Uri "http://192.168.129.68/tim/ci-cd-example.git/info/refs?service=git-receive-pack" `
    -Headers @{Authorization=("Basic " + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("tim:glpat-xxxxxxxxxxxxxxxxxx")))}

This gave me a 200 OK back which should indicate that the token is actually working
I also checked windows credentials manager for entries but no luck which is also good.
I’m still thinking about git in visual studio but i find it weird that i get an 401 authentication failed tough.

I have found the solution and it was indeed lying in visual studiio but I don’t know why.

I checked git settings in visual studio and saw that fetch and push had different access token, assuming that the token being used for push is invalid.

I copied the token from fetch to push and it worked.

To make things easier I checked the checkbox fetch is the same as push.