applications.md 2.49 KB
Newer Older
1 2
# Applications API

3
> [Introduced](https://gitlab.com/gitlab-org/gitlab-foss/merge_requests/8160) in GitLab 10.5.
4

5
Applications API operates on OAuth applications for:
6

7 8
- [Using GitLab as an authentication provider](../integration/oauth_provider.md).
- [Allowing access to GitLab resources on a user's behalf](oauth2.md).
9

10 11
NOTE: **Note:**
Only admin users can use the Applications API.
12

13 14 15
## Create an application

Create an application by posting a JSON payload.
16 17 18

Returns `200` if the request succeeds.

19
```text
20 21 22
POST /applications
```

23 24 25 26 27 28 29 30 31
Parameters:

| Attribute      | Type   | Required | Description                      |
|:---------------|:-------|:---------|:---------------------------------|
| `name`         | string | yes      | Name of the application.         |
| `redirect_uri` | string | yes      | Redirect URI of the application. |
| `scopes`       | string | yes      | Scopes of the application.       |

Example request:
32

33
```sh
34
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" --data "name=MyApplication&redirect_uri=http://redirect.uri&scopes=" https://gitlab.example.com/api/v4/applications
35 36 37 38 39
```

Example response:

```json
40
{
41
    "id":1,
42
    "application_id": "5832fc6e14300a0d962240a8144466eef4ee93ef0d218477e55f11cf12fc3737",
43
    "application_name": "MyApplication",
44 45 46 47
    "secret": "ee1dd64b6adc89cf7e2c23099301ccc2c61b441064e9324d963c46902a85ec34",
    "callback_url": "http://redirect.uri"
}
```
48 49 50 51 52

## List all applications

List all registered applications.

53
```text
54 55 56
GET /applications
```

57 58 59
Example request:

```sh
60
curl --request GET --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/applications
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
```

Example response:

```json
[
    {
        "id":1,
        "application_id": "5832fc6e14300a0d962240a8144466eef4ee93ef0d218477e55f11cf12fc3737",
        "application_name": "MyApplication",
        "callback_url": "http://redirect.uri"
    }
]
```

76 77
NOTE: **Note:**
The `secret` value will not be exposed by this API.
78 79 80 81 82 83 84

## Delete an application

Delete a specific application.

Returns `204` if the request succeeds.

85
```text
86 87 88 89 90
DELETE /applications/:id
```

Parameters:

91 92 93
| Attribute | Type    | Required | Description                                         |
|:----------|:--------|:---------|:----------------------------------------------------|
| `id`      | integer | yes      | The id of the application (not the application_id). |
94

95 96 97
Example request:

```sh
98
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/applications/:id
99
```