应用程序 API

  • Tier: 基础版, 专业版, 旗舰版
  • Offering: 私有化部署

使用此 API 与实例范围的 OAuth 应用程序交互:

您无法使用此 API 管理群组应用程序或个人用户应用程序。

先决条件:

  • 您必须具有实例的管理员访问权限。

创建一个应用程序#

通过发送 JSON 数据负载来创建一个应用程序。

如果请求成功,则返回 200

plaintext
POST /applications

支持的属性:

属性类型是否必须描述
namestring应用程序的名称。
redirect_uristring应用程序的重定向 URI。
scopesstring应用程序的范围。您可以通过空格分隔每个范围来指定多个范围。
confidentialboolean应用程序用于客户端密钥可以保密的地方。原生移动应用程序和单页应用程序被认为是非保密的。如果未提供,默认为 true

示例请求:

shell
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" \ --data "name=MyApplication&redirect_uri=http://redirect.uri&scopes=api read_user email" \ "https://gitlab.example.com/api/v4/applications"

示例响应:

json
1{ 2 "id":1, 3 "application_id": "5832fc6e14300a0d962240a8144466eef4ee93ef0d218477e55f11cf12fc3737", 4 "application_name": "MyApplication", 5 "secret": "ee1dd64b6adc89cf7e2c23099301ccc2c61b441064e9324d963c46902a85ec34", 6 "callback_url": "http://redirect.uri", 7 "confidential": true 8}

列出所有应用程序#

列出所有已注册的应用程序。

plaintext
GET /applications

示例请求:

shell
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/applications"

示例响应:

json
1[ 2 { 3 "id":1, 4 "application_id": "5832fc6e14300a0d962240a8144466eef4ee93ef0d218477e55f11cf12fc3737", 5 "application_name": "MyApplication", 6 "callback_url": "http://redirect.uri", 7 "confidential": true 8 } 9]
此 API 不会公开 `secret` 值。

删除一个应用程序#

删除特定的应用程序。

如果请求成功,则返回 204

plaintext
DELETE /applications/:id

支持的属性:

属性类型是否必须描述
idinteger应用程序的 ID(不是 application_id)。

示例请求:

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

更新应用程序密钥#

History
    • 引入于极狐GitLab 16.11。

更新应用程序密钥。如果请求成功,则返回 200

plaintext
POST /applications/:id/renew-secret

支持的属性:

属性类型是否必须描述
idinteger应用程序的 ID(不是 application_id)。

示例请求:

shell
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/applications/:id/renew-secret"

示例响应:

json
1{ 2 "id":1, 3 "application_id": "5832fc6e14300a0d962240a8144466eef4ee93ef0d218477e55f11cf12fc3737", 4 "application_name": "MyApplication", 5 "secret": "ee1dd64b6adc89cf7e2c23099301ccc2c61b441064e9324d963c46902a85ec34", 6 "callback_url": "http://redirect.uri", 7 "confidential": true 8}