Gitlab API: How to generate the private token

rodvlopes picture rodvlopes · May 13, 2014 · Viewed 25.5k times · Source

This is what I tried:

curl http://git.ep.petrobras.com.br/api/v3/session --data-urlencode 'login=myUser&password=myPass'

Answer:

{"message":"401 Unauthorized"}

Answer

Steven V picture Steven V · May 19, 2014

The problem is the data-urlencode CURL option. Since it's an HTTP POST you don't need to URL encode the data, and is actually encoding the & into & and causing your issue. Instead use the --data option.

curl http://git.ep.petrobras.com.br/api/v3/session --data 'login=myUser&password=myPass'

Also, be careful sending credentials over plain HTTP. It could be easily sniffed.