Louis CASSEDANNE
Louis CASSEDANNE

Reputation: 271

Retrieve users private token with Gitlab python API

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 ?

Upvotes: 4

Views: 1561

Answers (2)

djuarezg
djuarezg

Reputation: 2541

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.

Upvotes: 0

ttylec
ttylec

Reputation: 303

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

Upvotes: 2

Related Questions