Working with the API sudo command
In GitLab, all API requests you make are completed as the user you're logged in as. As an administrator, you might want to perform a specific action on behalf of one of your users. This can be done by asking them for their private_token
key, but GitLab has a better way of performing these kind of operations. You can run a command with the sudo
parameter.
The sudo
parameter has to be given with capitals, and as a value for this parameter, you have to provide the username for the user.
So, for example, if we want to list all projects but want to do this as the user John
, our endpoint call will look as follows:
http://yourdomain/api/v3/projects?private_token=your_token&SUDO=john
If the user given as the SUDO
parameter ...
Get GitLab Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.