401 on using NuGet repository

Describe your question in as much detail as possible:
I created a group with some projects in it. The projects are dotnet libraries, i want to package as NuGet and publish them in the package repository.
First part is already working:
I am able to create the package and publish it to the repository.

  • What are you seeing, and how does it differ from what you expect to see?

But when i try to use the package in another project, i get the following messages:

error: Unable to load the serviceindex for source xxx
error: Response status code does not indicate success: 401 (Unauthorized)

I created a personal api token and used that when adding the NuGet source.

nuget source Add -Name "MyGitLabRepo" -Source "https://gitlab.com/api/v4/projects/<MyProject-ID>/packages/nuget/index.json" -UserName <MyTokenName> -Password <MyToken>

I would expect the token to work and the package to be installed on my project.

  • What version are you on (Hint: /help) ? and are you using self-managed or gitlab.com?
    I’m on gitlab.com (free)

  • What troubleshooting steps have you already taken? Can you link to any docs or other resources so we know where you have been?

Already tried to create a new token in case i had a typo.

Hi @cloudcuckoohome :wave:

Just to be sure, you used a Personal Access Token so in -UserName <MyTokenName> you used your own username right? Not a token name :slightly_smiling_face:

1 Like

Hi @zillemarco
I used the tokenname.

But i also tried with my username an password and it didn’t work.

But you gave me the hint to the solution :wink:
I tried with my username and the token and that worked :star_struck:

Yup :slightly_smiling_face:

@cloudcuckoohome with Personal Access Tokens you need your username, with Deploy Tokens you need the token name :wink:

Glad you got this sorted out! :smile: