Docs Update: Add API endpoint for `personal_access_token` to return information about the PAT thats being used
Proposal
Currently the API has an endpoint for /personal_access_tokens which have the ability to:
- list personal access tokens
- get a single access token by id
- revoke a personal access token
- create a personal access token.
However a feature that I believe is missing, is the ability to pass a PAT into the API endpoint and for the API to return information about the PAT thats being used.
The API needs an endpoint exposed at /personal_access_token that runs this ruby code https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/api/entities/personal_access_token.rb and returns the access token details.
This would be very similar to the /user endpoint which returns the current user information based on the access token being used.
New endpoint:
GET /personal_access_token
Example request:
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/personal_access_token"
Example response:
{
"id": 4,
"name": "Test Token",
"revoked": false,
"created_at": "2020-07-23T14:31:47.729Z",
"scopes": [
"api"
],
"user_id": 24,
"last_used_at": "2021-10-06T17:58:37.550Z",
"active": true,
"expires_at": null
}