​ Bad Token: Internal Error; Reason: internalError

  • 4 April 2022
  • 4 replies
  • 204 views

Badge

Hi Team, 

Can you please check why i am getting this error: ​ Bad Token: Internal Error; Reason: internalError

Yesterday, I was able to get embed link but today it is not working. I am using this code to generate my JWT token. 

app.get("/getToken", (req, res) => {

  const user = {

      "iss": "'" + process.env.CLIENTID_WB + "'"

  }

  let accessToken = jwt.sign(user,"'" + process.env.CLIENT_SKEY_WB+ "'", {algorithm:'HS256', expiresIn: '1h'})

  console.log("Access Token ==> " + accessToken);

  return res.status(201).json({

    accessToken  

  });

});

Can you please check why it is not working?

Thank you!


4 replies

Userlevel 6
Badge +4

Hi @Himanshu Tomar,

Thanks for reaching out about this, and sorry to hear about the trouble you’re facing with JWT token generation. Happy to help out however I can!

In taking a quick look at the code you’re using to generate your JWT token, I don't immediately see an issue, though I understand this was working for you at one point. As a first step, can I kindly ask that you check each of the following items?

  1. Have you tried decoding the token that’s throwing the error and comparing the time of the error with the exact time reflected in the timestamp of the JWT token itself?
  2. Have you changed any of your .env variables by chance?
  3. Have you tried refreshing your Client Secret to see if this helps?
  4. Another common error with JWT tokens — please ensure that your server time/machine time is in sync. This can affect the timestamp generated for the JWT and cause this type of error if they fall out of sync.
  5. Have you tried testing with one of the jwt.io libraries, such as this JS or this Node one (to rule out an issue with the JWT generation code you’re currently using)?

Let me know when you have a chance to double check these items and test with another library. Thanks, and we’ll keep an eye out for your reply.

Best,

Miro Developer Relations

Badge

Hi @Will Bishop ,

Thanks for the reply,

Regardings points,

  1. time for token generation was 22:25:53
    and time for the error was 22:25:54
  2. Nope, I just cross-verified.
  3. Yes, I tried but is not changing.

So, these are the findings, can you please check and let me know what should be the next step.

Regards,

Himanshu 

 

Userlevel 5
Badge +1

Hi @Himanshu Tomar

 

Can you please send me in private message the client id you use for your app. Just want to check that the client id you use is enabled to use anonymous boards.

 

Will shared some good points above about using one of the client library to check there is no issue with your code. We haven’t deployed any updated recently. What changed on your side between the moment it worked and it stopped working?

 

 

Badge

Hi @Anthony Roux @Will Bishop ,

the issue was on my side, I was adding quotes around the keys which was causing the issue, thank you so much for your help.

Reply