4

I am trying to retrieve all users' private token and SSH keys with gitlab API (v4) using an admin private token in my curl requests.

I can get a user SSH key by running the following command :

curl --header "PRIVATE-TOKEN: my_admin_token" "https://gitlab.my_gitlab.com/api/v4/users/user_id/keys"

But I can't find a similar way to get his private token (I need it for further applications in a python script). How can I do that ?

2 Answers2

2

It seems that it is impossible. When you create token you need to save it since you cannot access it later (see attached screenshot):

enter image description here

ttylec
  • 303
  • 1
  • 7
  • I understand now that it is not possible for the Personal Access Token (thank you for this info), but I am also looking for the "Private token", which can be found in Settings -> Account at any time. So I suppose it should be retrievable with gitlab API? – Louis CASSEDANNE Nov 10 '17 at 17:33
0

Those tokens are not available through Gitlab API, on the other hand, if you want to make API calls as someone else, you can do so with https://docs.gitlab.com/ee/api/README.html#sudo.

djuarezg
  • 2,307
  • 2
  • 20
  • 34