I have a Monday Code hosted app that I’m working on implementing webhooks for, but I’m having an issue getting a shortLivedToken.
This code handles the webhook POST call:
import { NextResponse } from 'next/server';
import jwt from 'jsonwebtoken';
import { headers } from 'next/headers';
export async function POST(request: Request) {
try {
const headersList = headers();
const authHeader = headersList.get('Authorization');
const token = authHeader!.replace('Bearer ', '');
const clientSecret = process.env.CLIENT_SECRET;
const decoded = jwt.verify(token, clientSecret!);
const accessToken = decoded.shortLivedToken;
}
catch (error) {
// handle error
}
}
and decoded
evaluates to:
{
"fields": {
"dat": {
"structValue": {
"fields": {
"client_id": {
"stringValue": "b11**********************",
"kind": "stringValue"
},
"app_version_id": {
"numberValue": 104******,
"kind": "numberValue"
},
"is_admin": {
"boolValue": true,
"kind": "boolValue"
},
"is_guest": {
"boolValue": false,
"kind": "boolValue"
},
"app_id": {
"numberValue": 101******,
"kind": "numberValue"
},
"install_id": {
"numberValue": 112*****,
"kind": "numberValue"
},
"user_kind": {
"stringValue": "admin",
"kind": "stringValue"
},
"user_id": {
"numberValue": 620******,
"kind": "numberValue"
},
"account_id": {
"numberValue": 238******,
"kind": "numberValue"
},
"is_view_only": {
"boolValue": false,
"kind": "boolValue"
},
"slug": {
"stringValue": "example-app",
"kind": "stringValue"
}
}
},
"kind": "structValue"
},
"exp": {
"numberValue": 173********,
"kind": "numberValue"
}
}
}
This is very different from the shape of the object in the Authorization Header documentation:
{
"accountId": 1825528,
"userId": 4012689,
"aud": "https://www.yourserver.com/endpoint",
"exp": 1606808758,
"shortLivedToken": "SHORT_LIVED_TOKEN_HERE",
"iat": 1606808458
}
There’s this caveat in the documentation: “We will not issue a short-lived token if your app’s endpoints do not start with https://
.”
But my webhooks url starts with https://
. This is it: https://live1-service-23******-f43*******.us.monday.app/api/webhooks
My decoded token data is so drastically different from what’s in the docs. I’m not sure if I’m just totally off track or if the docs are outdated for this.
Any guidance would be sincerely appreciated!