Skip to content

Commit bc47a48

Browse files
add getPersonalAccessToken
1 parent e883f9e commit bc47a48

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,32 @@ public PersonalAccessToken rotatePersonalAccessToken(String id, Date expiresAt)
6464
Response response = post(Response.Status.OK, formData, "personal_access_tokens", id, "rotate");
6565
return (response.readEntity(PersonalAccessToken.class));
6666
}
67+
68+
/**
69+
* Get information about a given access token.
70+
* Only working with GitLab 16.0 and above.
71+
*
72+
* <pre><code>GitLab Endpoint: POST /personal_access_tokens/self</code></pre>
73+
*
74+
* @return the newly created PersonalAccessToken.
75+
* @throws GitLabApiException if any exception occurs
76+
*/
77+
public PersonalAccessToken getPersonalAccessToken() throws GitLabApiException {
78+
return getPersonalAccessToken("self");
79+
}
80+
81+
/**
82+
* Get a specific personal access token.
83+
* Only working with GitLab 16.0 and above.
84+
*
85+
* <pre><code>GitLab Endpoint: POST /personal_access_tokens/:id</code></pre>
86+
*
87+
* @param id ID of the personal access token
88+
* @return the specified PersonalAccessToken.
89+
* @throws GitLabApiException if any exception occurs
90+
*/
91+
public PersonalAccessToken getPersonalAccessToken(String id) throws GitLabApiException {
92+
Response response = get(Response.Status.OK, null, "personal_access_tokens", id);
93+
return (response.readEntity(PersonalAccessToken.class));
94+
}
6795
}

0 commit comments

Comments
 (0)