Book Image

Gitlab Cookbook

By : Jeroen van Baarsen
Book Image

Gitlab Cookbook

By: Jeroen van Baarsen

Overview of this book

Table of Contents (16 chapters)
GitLab Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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 is not found, the API will return a 403 code.