Skip to content

Commit edb0779

Browse files
committed
Add getPersonalAccessTokens()
1 parent 98f686b commit edb0779

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

gitlab4j-api/src/main/java/org/gitlab4j/api/PersonalAccessTokenApi.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package org.gitlab4j.api;
22

33
import java.util.Date;
4+
import java.util.List;
45

6+
import jakarta.ws.rs.core.GenericType;
57
import jakarta.ws.rs.core.Response;
68

79
import org.gitlab4j.api.models.PersonalAccessToken;
@@ -66,6 +68,20 @@ public PersonalAccessToken rotatePersonalAccessToken(String id, Date expiresAt)
6668
return (response.readEntity(PersonalAccessToken.class));
6769
}
6870

71+
/**
72+
* Get information about the personal access token used in the request header.
73+
* Only working with GitLab 16.0 and above.
74+
*
75+
* <pre><code>GitLab Endpoint: GET /personal_access_tokens</code></pre>
76+
*
77+
* @return the specified PersonalAccessToken.
78+
* @throws GitLabApiException if any exception occurs
79+
*/
80+
public List<PersonalAccessToken> getPersonalAccessTokens() throws GitLabApiException {
81+
Response response = get(Response.Status.OK, null, "personal_access_tokens");
82+
return response.readEntity(new GenericType<List<PersonalAccessToken>>() {});
83+
}
84+
6985
/**
7086
* Get information about the personal access token used in the request header.
7187
* Only working with GitLab 16.0 and above.

0 commit comments

Comments
 (0)