debian-mirror-gitlab/doc/api/applications.md

113 lines
3.2 KiB
Markdown
Raw Normal View History

2021-01-29 00:20:46 +05:30
---
2021-06-08 01:23:25 +05:30
stage: Manage
2022-04-04 11:22:00 +05:30
group: Authentication and Authorization
2022-11-25 23:54:43 +05:30
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/product/ux/technical-writing/#assignments
2021-01-29 00:20:46 +05:30
---
2021-11-11 11:23:49 +05:30
# Applications API **(FREE)**
2018-03-17 18:26:18 +05:30
2020-03-13 15:44:24 +05:30
> [Introduced](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/8160) in GitLab 10.5.
2018-03-17 18:26:18 +05:30
2021-04-29 21:17:54 +05:30
The Applications API operates on instance-wide OAuth applications for:
2018-03-17 18:26:18 +05:30
2019-03-02 22:35:43 +05:30
- [Using GitLab as an authentication provider](../integration/oauth_provider.md).
- [Allowing access to GitLab resources on a user's behalf](oauth2.md).
2018-12-13 13:39:08 +05:30
2021-04-29 21:17:54 +05:30
The Applications API cannot be used to manage group applications or applications of individual users.
2021-02-22 17:27:13 +05:30
NOTE:
2021-03-11 19:13:27 +05:30
Only administrator users can use the Applications API.
2018-03-17 18:26:18 +05:30
2019-03-02 22:35:43 +05:30
## Create an application
Create an application by posting a JSON payload.
2018-03-17 18:26:18 +05:30
Returns `200` if the request succeeds.
2020-05-24 23:13:21 +05:30
```plaintext
2018-03-17 18:26:18 +05:30
POST /applications
```
2019-03-02 22:35:43 +05:30
Parameters:
2020-03-13 15:44:24 +05:30
| Attribute | Type | Required | Description |
|:---------------|:--------|:---------|:---------------------------------|
| `name` | string | yes | Name of the application. |
| `redirect_uri` | string | yes | Redirect URI of the application. |
2021-11-18 22:05:49 +05:30
| `scopes` | string | yes | Scopes of the application. You can specify multiple scopes by separating each scope using a space. |
2021-02-22 17:27:13 +05:30
| `confidential` | boolean | no | The application is used where the client secret can be kept confidential. Native mobile apps and Single Page Apps are considered non-confidential. Defaults to `true` if not supplied |
2019-03-02 22:35:43 +05:30
Example request:
2018-03-17 18:26:18 +05:30
2020-03-13 15:44:24 +05:30
```shell
2021-09-04 01:27:46 +05:30
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" \
2021-11-18 22:05:49 +05:30
--data "name=MyApplication&redirect_uri=http://redirect.uri&scopes=api read_user email" \
2021-09-04 01:27:46 +05:30
"https://gitlab.example.com/api/v4/applications"
2018-03-17 18:26:18 +05:30
```
Example response:
```json
{
2018-12-13 13:39:08 +05:30
"id":1,
2018-03-17 18:26:18 +05:30
"application_id": "5832fc6e14300a0d962240a8144466eef4ee93ef0d218477e55f11cf12fc3737",
2018-12-13 13:39:08 +05:30
"application_name": "MyApplication",
2018-03-17 18:26:18 +05:30
"secret": "ee1dd64b6adc89cf7e2c23099301ccc2c61b441064e9324d963c46902a85ec34",
2020-03-13 15:44:24 +05:30
"callback_url": "http://redirect.uri",
"confidential": true
2018-03-17 18:26:18 +05:30
}
```
2018-12-13 13:39:08 +05:30
## List all applications
List all registered applications.
2020-05-24 23:13:21 +05:30
```plaintext
2018-12-13 13:39:08 +05:30
GET /applications
```
2019-03-02 22:35:43 +05:30
Example request:
2020-03-13 15:44:24 +05:30
```shell
2020-06-23 00:09:42 +05:30
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/applications"
2018-12-13 13:39:08 +05:30
```
Example response:
```json
[
{
"id":1,
"application_id": "5832fc6e14300a0d962240a8144466eef4ee93ef0d218477e55f11cf12fc3737",
"application_name": "MyApplication",
2020-03-13 15:44:24 +05:30
"callback_url": "http://redirect.uri",
"confidential": true
2018-12-13 13:39:08 +05:30
}
]
```
2021-02-22 17:27:13 +05:30
NOTE:
The `secret` value is not exposed by this API.
2018-12-13 13:39:08 +05:30
## Delete an application
Delete a specific application.
Returns `204` if the request succeeds.
2020-05-24 23:13:21 +05:30
```plaintext
2018-12-13 13:39:08 +05:30
DELETE /applications/:id
```
Parameters:
2019-12-04 20:38:33 +05:30
| Attribute | Type | Required | Description |
|:----------|:--------|:---------|:----------------------------------------------------|
2020-05-24 23:13:21 +05:30
| `id` | integer | yes | The ID of the application (not the application_id). |
2018-12-13 13:39:08 +05:30
2019-03-02 22:35:43 +05:30
Example request:
2020-03-13 15:44:24 +05:30
```shell
2020-06-23 00:09:42 +05:30
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/applications/:id"
2018-12-13 13:39:08 +05:30
```