Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Identify incorrect Personal Access Token

Hi team,

   For a product that we are building, we take PAT as an input from our customers and use it to call customer's Confluence Server URL. If an incorrect PAT is provided, we should communicate the same to our customers. Unfortunately, Confluence server doesn't return an appropriate HTTP error code, instead returns a 200 HTTP code always, like a correct PAT (only the response content differs). So, it's hard to distinguish an incorrect PAT unless we parse the response, which I don't think is a reliable way. However basic authentication with username, password results in appropriate HTTP codes - for correct credentials, 200 and 401 for incorrect ones.

For your reference, below are curl outputs when I queried Confluence spaces with PAT  -

Query space with a correct PAT -

$ % curl -iH "Authorization: Bearer <correct PAT>" https://confluence.integ.***REDACTED***/rest/api/space

HTTP/2 200 

date: Mon, 01 Aug 2022 05:52:32 GMT

content-type: application/json

server: nginx/1.19.2

set-cookie: JSESSIONID=916B87FE907B2D7A47BF88AEC027A0D4; Path=/; HttpOnly

x-seraph-loginreason: OK

x-ausername: admin

cache-control: no-store

expires: Thu, 01 Jan 1970 00:00:00 GMT

x-content-type-options: nosniff

{"results":[{"id":560037,"key":"1SPAC","name":"1_space","type":"global","_links":{"webui":"/display/1SPAC","self":"https://confluence.integ.***REDACTED***/rest/api/space/1SPAC"},"_expandable":{"metadata":"","icon":"","description":"","retentionPolicy":"","homepage":"/rest/api/content/419305"}},{"id":557416,"key":"ARC","name":"ARC","type":"global","_links":{"webui":"/display/ARC","self":"https://confluence.integ.***REDACTED***/rest/api/space/ARC"},"_expandable":{"metadata":"","icon":"","description":"","retentionPolicy":"","homepage":"/rest/api/content/396145"}},{"id":561910,"key":"BLAN","name":"Blank_Space_Test","type":"global","_links":{"webui":"/display/BLAN","self":"https://confluence.integ.***REDACTED***/rest/api/space/BLAN"},"_expandable":{"metadata":"","icon":"","description":"","retentionPolicy":"","homepage":"/rest/api/content/4895011"}},{"id":561909,"key":"~confluence-space-admin","name":" confluence-space-admin","type":"personal","_links":{"webui":"/spaces/viewspace.action?key=~confluence-space-admin","self":"https://confluence.integ.***REDACTED***/rest/api/space/~confluence-space-admin"} ... [TRUNCATED]

Query space with an incorrect PAT - 

% curl -iH "Authorization: Bearer <incorrect PAT>" https://confluence.integ.***REDACTED***/rest/api/space 

HTTP/2 200 

date: Mon, 01 Aug 2022 05:52:46 GMT

content-type: application/json

server: nginx/1.19.2

set-cookie: JSESSIONID=FBE9C5B2F91504182F3319E6EEA7A54B; Path=/; HttpOnly

cache-control: no-store

expires: Thu, 01 Jan 1970 00:00:00 GMT

x-content-type-options: nosniff



Could you please help me understand if this is an expected behavior with PAT and if there is any reliable way to identify an incorrect PAT?


Thank you!

1 answer

Hi @Kai Gao . The REST API documentation tells that it is an expected behavior. The response code is always 200 . 

Some advice: Can you analyse field results?  I'm not sure, but may be. If it is empty then...

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events