Forums

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

JWT format is invalid when /installed is called when reinstalling a Bitbucket app

Paul Woolley July 8, 2022

(Cross posted here too)

 

Problem:

I am seeing a JWT format error when re-installing a Bitbucket connect app:

{} Authentication verification error (401): Invalid JWT: Unexpected token m in JSON at position 0

To reproduce:

  1. Create, run and install the sample Bitbucket connect app according to the "getting started" guide at https://developer.atlassian.com/cloud/bitbucket/getting-started/
  2. Re-install the app by re-visiting the installation link from step 9 of the "getting started" guide.

Expected:

The application is re-installed without error.

Actual:

The call to "/installed" results in a 401 error being thrown:

{} Authentication verification error (401): Invalid JWT: Unexpected token m in JSON at position 0
POST /installed 401 33234.738 ms - 53

Notes:

Looking at the incoming request, I can see the Authorisation header looks like this:

Authorization: JWT b'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJhcmk6Y2xvdWQ6Yml0YnVja2V0OjphcHAve2I2YzRiNzcwLWZjMDgtNDcxMS05NTdkLTU2MGExMzU4YjM4ZH0vZXhhbXBsZS1hcHAtMTIzNDU2IiwiZXhwIjoxNjU3MzAwMDg0LCJpYXQiOjE2NTcyOTY0ODQsInFzaCI6IjRhMmUxZGU4Y2E3NGU2Y2FmZTg4NjJkMzMyZmEzYWM3YThlNTFlNjkyYmM2ZDc5OGVhNGRmZWRjMTQ5NDhiZjQiLCJhdWQiOiJhcmk6Y2xvdWQ6Yml0YnVja2V0OjphcHAve2I2YzRiNzcwLWZjMDgtNDcxMS05NTdkLTU2MGExMzU4YjM4ZH0vZXhhbXBsZS1hcHAtMTIzNDU2In0.PLgvhYcfdObBX6eEbxHzJxoajeNcjCaJBuGGdwtlzjQ'

Notice that the JWT starts with b' and also ends with a single quote.  This is causing an error in the "atlassian-jwt/dist/lib/jwt.js" module when decoding the JWT.

If you remove the leading b' and trailing quote then the JWT looks correct.  Something on the Atlassian/Bitbucket side seems to be generating wrapped/invalid JWTs when making that "/installed" API call.

1 answer

1 accepted

0 votes
Answer accepted
Paul Woolley July 13, 2022

This issue has now been resolved after Atlassian applied a fix on their side.

 

Also see here: https://community.developer.atlassian.com/t/jwt-format-is-invalid-when-installed-is-called-when-reinstalling-a-bitbucket-app/59747/1

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events