JWT Issue
# support
a
Greetings team, Out of nowhere, I started getting "JWT doesn't permit access. Hot tip, you may be missing "token" in your JWT." in my production. I didn't change anything. It was running a few hours ago. I tried it on my local environment where again, it was working smoothly, I got the same error.
v
Hi there! 👋 Sorry to hear you're experiencing JWT issues. I can't determine exactly what caused the sudden change in your JWT functionality since you didn't change anything and it was working previously. However, I can definitely help troubleshoot this "token" field missing error! Based on the information I found, here are some possible reasons and troubleshooting steps for your JWT issue: ## Possible Causes The error message "JWT doesn't permit access. Hot tip, you may be missing 'token' in your JWT" suggests there might be an issue with your JWT structure or configuration. According to [troubleshooting information](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1336414771309838448), this could be due to: 1. **Malformed JWT Token**: Your JWT might be incorrectly formatted or constructed 2. **Private Key Issues**: Problems with the private key configuration or format 3. **Authorization Header Problems**: The JWT might not be correctly included in the request header ## Troubleshooting Steps ### 1. Inspect Your JWT Payload You can use [jwt.io](https://jwt.io/) to decode and verify your JWT to see if the "token" field is actually missing from the payload. A JWT token should be well-formed with three parts separated by dots (header.payload.signature). ### 2. Verify JWT Format and Key Ensure your JWT is correctly formatted and signed with the proper private key. The private key should typically be in PEM format according to [Vapi's requirements](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1336360744916226168). ### 3. Check Authorization Header Confirm the token is being sent correctly in the authorization header as:
Copy code
Authorization: Bearer {token}
### 4. Review API Key and Configuration - Verify you're using the correct API key from Vapi - Check if your environment variables (e.g.,
ORG_ID
and
PRIVATE_KEY
) are correctly set up
- Confirm the private key configuration in the Vapi Dashboard matches the one you're using ### 5. Check for Recent Changes Even though you didn't change your code, there might have been: - Changes to the Vapi platform - Expired tokens or keys - Network or server configuration changes Is there anything specific from these troubleshooting steps you'd like me to elaborate on? Sources: - [JWT Troubleshooting](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1336414771309838448) - [JWT Configuration Issues](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1336360744916226168) - [JWT Payload Inspection](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1336414771309838448) - [General JWT Troubleshooting Steps](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1336360744916226168)
a
Here's my token refresh mechanism. I have checked the necessary environment variables and they are present. And as you can see, I didn't change anything in this mechanism since the last 4 weeks. Plus, there have been no releases to prod in the last 1 week, so this error is a complete surprise to me. https://cdn.discordapp.com/attachments/1353414660212391937/1353416062875729920/image.png?ex=67e1926e&is=67e040ee&hm=c5929ccf55b476c4d97af42ce7098737bfd59db857fd2832fe18525fe23ccd9b&
t
same here, did you fix it ? @AKG ?
a
Nope, I wasn't able to. I even checked their sdk and added some console.logs, and my token was present. I am fairly certain it's an issue at their end. Are you facing the same issue and did it start happening today?
t
i just fix it bro
i will explain below how to do it
instead of generating the jwt , just replace the bearer authentication to this Authorization: without the bearer prefix
a
wait what? how does that even work
t
ahaha it seems they have 2 authentication methods, generating a tokem with the PRIVATEKEY and ORGId but it seems they also accept just receiving the private key
a
ahh makes sense. Let me try that.
Damn! It's working
That's one heck of a find. Thanks!
t
My pleasure bro ! Best of luck !
m
Passing just PRIVATEKEY in "Authorization:" header does not seem to work. We didn't change anything. Looks like a problem on VAPI's side.
s
We didn't make any changes when you pass a private key inside the Authorization header and append it after the Bearer keyword. We extract the key, validate the key, and then either accept or reject your request. Similarly, when you pass the token, signed by your private key, we check if it's valid or not, then proceed next. Both of these methods are available to you directly passing the key or sending out a token signed by your private key. So both of them work; it's a feature, not a bug
k
Marking this ticket as Solved ✅
m
Passing
Bearer ${privateKey}
does work. So there is now indeed a workaround. But the token based auth is still broken. It would be nice to get it working.
a
Yeah, the token based auth is broken. Private key does work.
3 Views