REST API
The API Token Authentication app currently provides a few REST API endpoints. Please find below a summary of what can be done already.
Create a new token
Create a new token by providing its description as follows. The response will contain the token automatically generated.
- curl -v -u user:password -d '{"tokenDescription":"<enter-your-token-description-here>"}' POST https://<your-jira-or-confluence>/rest/de.resolution.apitokenauth/latest/user/token --header "Content-Type: application/json"
Update a token description
- curl -v -u user:password -d '{"tokenDescription":"Updated token description"}' -X PATCH https://<your-jira-or-confluence>/rest/de.resolution.apitokenauth/latest/user/token/<token-id> --header "Content-Type: application/json"
List all tokens
To get an overview of what tokens you've added for your user and to grab an id of one to update or delete it, execute the request below.
You may omit the pipe symbol and python command at the end, it is just for beautifying the JSON response.
- curl -v -u user:password GET https://<your-jira-or-confluence>/rest/de.resolution.apitokenauth/latest/user/token/ | python -mjson.tool
which produces output like:
- [
- {
- "created": 1573814077364,
- "description": "Automation token",
- "id": 4,
- "lastAccessed": 1573814464012
- }
- ]
Delete a token
Grab a token ID retrieved with the previous call and put it to end of the call:
- curl -v -u user:password -X DELETE https://<your-jira-or-confluence>/rest/de.resolution.apitokenauth/latest/user/token/<token-id>
Delete all tokens for a user
This call will work for sysadmins only and otherwise throw 403. Please note that the user key is passed, which is different than the name *.
- curl -v -u admin:password -X DELETE https://<your-jira-or-confluence>/rest/de.resolution.apitokenauth/latest/user/token/deleteAllFor/<user-key-not-user-name>
Get User Key for a User
* you can get a user's key by using the REST API as an admin
The result will contain a key or userKey field (Jira or Confluence)
Jira
- curl -v -u admin:password GET https://<your-jira>/rest/api/2/user?username=some.username | python -mjson.tool
- {
- "active": true,
- "applicationRoles": {
- "items": [],
- "size": 1
- },
- "avatarUrls": {
- "16x16": "https://www.gravatar.com/avatar/9c7da4947106c84fe2c18c1a48747c54?d=mm&s=16",
- "24x24": "https://www.gravatar.com/avatar/9c7da4947106c84fe2c18c1a48747c54?d=mm&s=24",
- "32x32": "https://www.gravatar.com/avatar/9c7da4947106c84fe2c18c1a48747c54?d=mm&s=32",
- "48x48": "https://www.gravatar.com/avatar/9c7da4947106c84fe2c18c1a48747c54?d=mm&s=48"
- },
- "displayName": "Some User",
- "emailAddress": "some@user.com",
- "expand": "groups,applicationRoles",
- "groups": {
- "items": [],
- "size": 1
- },
- "key": "JIRAUSER10100",
- "locale": "en_US",
- "name": "Some User",
- "self": "https://<your-jira>/rest/api/2/user?username=some.username",
- "timeZone": "GMT"
- }
Confluence
- curl -v -u admin:password GET https://<your-confluence>/rest/api/user?username=some.username | python -mjson.tool
- {
- "_expandable": {
- "status": ""
- },
- "_links": {
- "base": "https://<your-confluence>",
- "context": "",
- "self": "https://<your-confluence>/rest/api/user?key=e4fc80a46ebbdf4c016fa42e69be01f8"
- },
- "displayName": "some.username",
- "profilePicture": {
- "height": 48,
- "isDefault": true,
- "path": "/images/icons/profilepics/default.svg",
- "width": 48
- },
- "type": "known",
- "userKey": "e4fc80a46ebbdf4c016fa42e69be01f8",
- "username": "some.username"
- }
