Commit 2ddaf0038710d057e96f8211036399aa65d3ddb4

Authored by Felix Gilcher
1 parent bd948549

Added documentation for passing the token as header

The documentation was unclear about how to pass the api private token as
header. Updated the doc to include the nessesary information bits and
added an example using the curl command line client.
Showing 1 changed file with 8 additions and 1 deletions   Show diff stats
doc/api/README.md
1 1 # GitLab API
2 2  
3   -All API requests require authentication. You need to pass a `private_token` parameter by url or header. You can find or reset your private token in your profile.
  3 +All API requests require authentication. You need to pass a `private_token` parameter by url or header. If passed as header, the header name must be "PRIVATE-TOKEN" (capital and with dash instead of underscore). You can find or reset your private token in your profile.
4 4  
5 5 If no, or an invalid, `private_token` is provided then an error message will be returned with status code 401:
6 6  
... ... @@ -18,6 +18,13 @@ Example of a valid API request:
18 18 GET http://example.com/api/v3/projects?private_token=QVy1PB7sTxfy4pqfZM1U
19 19 ```
20 20  
  21 +Example for a valid API request using curl and authentication via header:
  22 +
  23 +```
  24 +curl --header "PRIVATE-TOKEN: QVy1PB7sTxfy4pqfZM1U" "http://example.com/api/v3/projects"
  25 +```
  26 +
  27 +
21 28 The API uses JSON to serialize data. You don't need to specify `.json` at the end of API URL.
22 29  
23 30 #### Pagination
... ...