How to get personal token id list along with username, email address and user key using Database query

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

The steps outlined on this article are provided AS-IS. This means we've had reports of them working for some customers — under certain circumstances — yet are not officially supported, nor can we guarantee they'll work for your specific scenario.

You may follow through and validate them on your own non-prod environments prior to production or fall back to supported alternatives if they don't work out.

We also invite you to reach out to our Community for matters that fall beyond Atlassian's scope of support!

 

Summary

Database query to get a list of users with details such as username, email address and user key along with token id for users.

Environment

Confluence Data center 

Solution

Always back up your data before performing any modifications to the database. If possible, test any alter, insert, update, or delete SQL commands on a staging server first.

Below query will get you username, email address, user key and token id for all the users 

(warning) Below query has been tested with postgreSQL , MySQL and Oracle 

PostgreSQL
SELECT CU.USER_NAME ,CU.EMAIL_ADDRESS ,UM.USER_KEY , AFPT."TOKEN_ID"  
FROM CWD_USER CU ,USER_MAPPING UM,"AO_81F455_PERSONAL_TOKEN" AFPT  
WHERE CU.USER_NAME =UM.USERNAME AND UM.USER_KEY = AFPT."USER_KEY";
Oracle
SELECT CU.USER_NAME ,CU.EMAIL_ADDRESS ,UM.USER_KEY , AFPT."TOKEN_ID"  
FROM CWD_USER CU ,USER_MAPPING UM,"AO_81F455_PERSONAL_TOKEN" AFPT  
WHERE CU.USER_NAME =UM.USERNAME AND UM.USER_KEY = AFPT."USER_KEY";
MySQL
SELECT CU.USER_NAME ,CU.EMAIL_ADDRESS ,UM.USER_KEY , AFPT.TOKEN_ID  
FROM cwd_user CU ,user_mapping UM,AO_81F455_PERSONAL_TOKEN AFPT 
WHERE CU.USER_NAME =UM.USERNAME AND UM.USER_KEY = AFPT.USER_KEY;


We have one KB article on Confluence Data Model. , which will give you more details in case you wish to modify the above query - depending upon the requirement. 

Info

Personal access tokens (PATs) are a secure way to use scripts and integrate external applications with your Atlassian application. If an external system is compromised, you simply revoke the token instead of changing the password and consequently changing it in all scripts and integrations.

Personal access tokens are a safe alternative to using username and password for authentication with various services

More details about Using Personal Access Tokens can be found in the document.

Last modified on Dec 10, 2024

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.