Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tatuya Kamada
gitlab-ce
Commits
09dd6a7e
Commit
09dd6a7e
authored
Jan 04, 2017
by
Simon Vocella
Committed by
Tiago Botelho
Feb 28, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add documentation and changelog entry for user personal access tokens api
parent
9ce56d2b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
152 additions
and
0 deletions
+152
-0
changelogs/unreleased/25367-add-impersonation-token.yml
changelogs/unreleased/25367-add-impersonation-token.yml
+4
-0
doc/api/README.md
doc/api/README.md
+1
-0
doc/api/personal_access_tokens.md
doc/api/personal_access_tokens.md
+61
-0
doc/api/users.md
doc/api/users.md
+86
-0
No files found.
changelogs/unreleased/25367-add-impersonation-token.yml
0 → 100644
View file @
09dd6a7e
---
title
:
Manage user personal access tokens through api and add impersonation tokens
merge_request
:
8350
author
:
Simon Vocella @voxsim
doc/api/README.md
View file @
09dd6a7e
...
...
@@ -8,6 +8,7 @@ under [`/lib/api`](https://gitlab.com/gitlab-org/gitlab-ce/tree/master/lib/api).
Documentation for various API resources can be found separately in the
following locations:
-
[
Access Tokens
](
personal_access_tokens.md
)
-
[
Award Emoji
](
award_emoji.md
)
-
[
Branches
](
branches.md
)
-
[
Broadcast Messages
](
broadcast_messages.md
)
...
...
doc/api/personal_access_tokens.md
0 → 100644
View file @
09dd6a7e
# Personal Access Token
## List
```
GET /personal_access_tokens
```
An example:
```
json
[
{
"id"
:
1
,
"name"
:
"mytoken"
,
"revoked"
:
false
,
"expires_at"
:
"2017-01-04"
,
"scopes"
:
[
'api'
],
"active"
:
true
}
]
```
In addition, you can filter users based on state:
`all`
,
`active`
and
`inactive`
```
GET /personal_access_tokens?state=all
```
```
GET /personal_access_tokens?state=active
```
```
GET /personal_access_tokens?state=inactive
```
## Create
```
POST /personal_access_tokens
```
Parameters:
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
|
`name`
| string | yes | The name of the personal access token |
|
`expires_at`
| date | no | The expiration date of the personal access token |
|
`scopes`
| array | no | The array of scopes of the personal access token |
## Revoke
```
DELETE /personal_access_tokens/:personal_access_token_id
```
Parameters:
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
|
`personal_access_token_id`
| integer | yes | The ID of the personal access token |
doc/api/users.md
View file @
09dd6a7e
...
...
@@ -827,3 +827,89 @@ Example response:
}
]
```
## Retrieve user personal access tokens
It retrieves every personal access token of the user. Note that only administrators can do this.
```
GET /users/:user_id/personal_access_tokens
```
Parameters:
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
|
`user_id`
| integer | yes | The ID of the user |
An example:
```
json
[
{
"id"
:
1
,
"name"
:
"mytoken"
,
"revoked"
:
false
,
"expires_at"
:
"2017-01-04"
,
"scopes"
:
[
'api'
],
"active"
:
true
,
"impersonation"
:
false
,
"token"
:
"9koXpg98eAheJpvBs5tK"
}
]
```
In addition, you can filter users based on state:
`all`
,
`active`
and
`inactive`
```
GET /users/:user_id/personal_access_tokens?state=all
```
```
GET /users/:user_id/personal_access_tokens?state=active
```
```
GET /users/:user_id/personal_access_tokens?state=inactive
```
Finally, you can filter based on impersonation:
`true`
or
`false`
.
```
GET /users/:user_id/personal_access_tokens?impersonation=true
```
## Create a personal access token
It creates a new personal access token. Note that only administrators can do this.
If you set the impersonation flag to true, you can impersonate the user and
performing both API calls and Git reads and writes. The user will not see these
tokens in his profile settings.
```
POST /users/:user_id/personal_access_tokens
```
Parameters:
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
|
`user_id`
| integer | yes | The ID of the user |
|
`name`
| string | yes | The name of the personal access token |
|
`expires_at`
| date | no | The expiration date of the personal access token |
|
`scopes`
| array | no | The array of scopes of the personal access token |
|
`impersonation`
| boolean | no | The impersonation flag of the personal access token |
## Revoke a personal access token
It revokes a personal access token. Note that only administrators can revoke impersonation tokens.
```
DELETE /users/:user_id/personal_access_tokens/:personal_access_token_id
```
Parameters:
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
|
`user_id`
| integer | yes | The ID of the user |
|
`personal_access_token_id`
| integer | yes | The ID of the personal access token |
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment