Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to delete Personal access token of specific user through API or DB Query

Jyoti Kumari
Contributor
January 13, 2025

Hello Everyone,

 

I wanted to know, how we can delete personal access token of specific user either through groovy script,Rest API or DB Query .I found below document ,to fetch list of access token-

 

https://community.atlassian.com/t5/Jira-questions/Jira-rest-API-to-get-list-of-user-tokens-and-expiry-dates/qaq-p/2009751

Working Query:-

SELECT DISTINCT u.lower_first_name || ' ' || u.lower_last_name AS full_name, pt."NAME" AS token_name, pt."LAST_ACCESSED_AT", pt."EXPIRING_AT",
bool_or(CASE
WHEN m.parent_name IN (SELECT group_id FROM globalpermissionentry WHERE permission IN ('ADMINISTER','SYSTEM_ADMIN')) THEN true
ELSE false
END) AS admin_rights
FROM "AO_81F455_PERSONAL_TOKEN" AS pt
INNER JOIN app_user AS k ON k.user_key = pt."USER_KEY"
INNER JOIN cwd_membership AS m ON m.lower_child_name = k.lower_user_name
INNER JOIN cwd_user AS u ON u.lower_user_name = k.lower_user_name
WHERE u.active = 1
AND ((pt."LAST_ACCESSED_AT" >= CURRENT_DATE) OR (pt."LAST_ACCESSED_AT" IS NULL))
GROUP BY u.lower_first_name, u.lower_last_name, pt."NAME", pt."LAST_ACCESSED_AT", pt."EXPIRING_AT";

Working REST API:- 

{{baseUrlOfYourInstance}}/rest/pat/latest/tokens

Is there any REST API to fetch PAT of specific user 

Thanks and Regards,
Jyoti

1 answer

0 votes
Aaron Pavez _ServiceRocket_
Community Champion
January 13, 2025

Hi @Jyoti Kumari 

It seems there is no Rest API to get the token. The one you've shared is only for the current user.

On the DB you can query the AO_81F455_PERSONAL_TOKEN to get the token name and user that created it.

Here is a good query for that:

https://community.atlassian.com/t5/Jira-questions/Re-Re-Jira-rest-API-to-get-expiry-date-of-user-token/qaq-p/2344045/comment-id/575989#M575989

Sadly only from the DB can we get that information.

Regards

 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
9.12.15
PRODUCT PLAN
STANDARD
TAGS
atlassian, likes for trees, atlassian community, social impact, tree planting campaign, community kudos, atlassian giving, environmental impact, sustainability, likes for good, atlassian social responsibility, community challenge

Make every click count—help us plant 50,000 trees! 🌳

Want to make your everyday Community actions directly contribute to reforestation? The Atlassian Community can achieve this goal by liking a post, attending an ACE, sending your peers kudos, and so much more!

Help us plant more trees
AUG Leaders

Atlassian Community Events