3

I am using glide as package management for my golang project. I can't able to get private repositories using glide get bezos.gitlab.com/gomock.

It asks username & password even i give correct credentials, it ended up throwing error. Please suggest any idea.

Zoe
  • 27,060
  • 21
  • 118
  • 148
Bezos
  • 45
  • 9

1 Answers1

4

It is nothing do with glide or any other package management tools. You have to set create and set gitlab access token in your git http.extraheader.

Go to your gitlab settings -> access token and create new access token, make sure to copy the token it available only once.

Then set these git global variables, now you can install private repositories using glide, go get, godep, etc.

git config --global http.extraheader "PRIVATE-TOKEN: YOUR_ACCESS_TOKEN"

git config --global url."git@bezos.gitlab.com:".insteadOf "https://bezos.gitlab.com/"

manigandand
  • 2,094
  • 2
  • 15
  • 21
  • Why are you setting the http header if you're configuring it to always use ssh? – JimB Mar 22 '18 at 16:50
  • 2
    @JimB When we try to install packages using `go get github.com/nsqio/go-nsq` it makes https call to get the package. That's why it always prompt username and password while trying to download. So that when you set `--global url` to refer as `git@path-to-clone` instead of `https://path-to-clone`. To get access to the repo, we are setting `http.extraheader private-token` . – manigandand Mar 22 '18 at 17:06