Draft: Getting username and email from Project and Group Access Token
-
Please check this box if this contribution uses AI-generated content (including content generated by GitLab Duo features) as outlined in the GitLab DCO & CLA. As a benefit of being a GitLab Community Contributor, you receive complimentary access to GitLab Duo.
This change adds two new pieces of information to GitLab access tokens: the username and email address of the user associated with each token.
Previously, when creating access tokens for groups or projects, you could only see basic details like when the token was created and whether it was active. Now, the system will also try to fetch and display the username and email of the account that the token belongs to.
The implementation works by using the newly created token to make an additional API call to GitLab to retrieve the user details. If this call fails (for example, if the token doesn't have sufficient permissions), the system will simply leave these fields empty rather than causing an error.
This enhancement is documented in both the group and project access token documentation, noting that retrieving this information requires the token to have either "read_api" or "api" scope permissions. The feature is purely informational - it doesn't change how tokens work, but provides more context about who owns each token.
Tests
Working example (PoC):
Related to #6374