Bad Token: The token was expected to have 3 parts, but got 1.; Reason: tokenInvalid

  • 11 September 2021
  • 1 reply
  • 600 views

I am trying to create anonymous editable board for my customers but getting this error as soon as I click on to create a board without registration. Kindly please help in this, I am ready to provide whatever information is required from my end to resolve this issue at the earliest.

Node.js Server:

const jwt = require('njwt');

app.post('/jwt', (req,res) => {

    var claims = {

        iss: 'XXX'

    }

    var Ejwt = jwt.create(claims,'XXX');

    res.send(Ejwt);

})

Client Side Code:

  async function getTokenFromServer() {

    await fetch('/jwt', {

          method: 'POST'

        })

    .then(res => res.json())

    .then((data) => {

        return data;

    })

  }


1 reply

Userlevel 2
Badge

Hey @Kanishk Rajvanshi! It seems like there was an error with creating the JWT token on the server side. While you were successful in creating the token itself, the Miro API was expected the token to contain 3 specific values, which were not all present.

`iss` – A token needs to be created with the issuer information, which you seem to have included. This value will need to be your client ID.
`exp` – In addition, the token needs an Expiration, which should be set for no more than 24 hours from the time the token is created.
And finally, the token needs to be signed using your Client Secret and an HMAC256 algorithm.

Here’s the section of the docs where these requirements are stated, as well as one example usage.
https://developers.miro.com/docs/editable-boards-for-anonymous-users#5-generate-jwt-on-your-backend

I hope this helps!
Joanna

Reply