'composer create-project from self-hosted GitLab instance

I'm trying to use the composer create-project vendor/name --repository=https://my.self-hosted-gitlab-instance.com/repository.git command to create project.

When I run the command I first have to put my credentials :

Authentication required (my.self-hosted-gitlab-instance.com):
  Username: myusername
  Password: 

I enter the correct credentials but then I have :

[Composer\Downloader\TransportException]                                                           


Invalid credentials for 'https://my.self-hosted-gitlab-instance.com/myrepository.git/packages.json', aborting. 


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source