Hey @Aditya Thanks for the reply. Here

Hey @Aditya Thanks for the reply. Here is the code snippet I am using to generate my JWT Token const express = require('express'); const jwt = require('jsonwebtoken'); const dotenv = require('dotenv'); const cors = require('cors'); const bodyParser = require('body-parser'); dotenv.config(); const app = express(); const PORT = process.env.PORT 5000; const corsOptions = { origin: 'https://ts-embed.bubbleapps.io ', optionsSuccessStatus: 200, }; app.use(cors(corsOptions)); app.use(bodyParser.json()); app.post('/generateToken', (req, res) => { const { userId, userName, email } = req.body; if (!userId !userName || !email) { return res.status(400).json({ error: 'Missing required user information.' }); } const payload = { sub: userId, name: userName, email: email, iat: Math.floor(Date.now() / 1000), exp: Math.floor(Date.now() / 1000) + (60 * 60), // Token valid for 1 hour }; const token = jwt.sign(payload, process.env.THOUGHTSPOT_SECRET); res.json({ token }); }); app.listen(PORT, () => { console.log(Token service is running on port ${PORT}); });
2 Replies
Aditya
Aditya6mo ago
Thanks @Chavda Jitendra for the code snippet. Are you able to get the token via this? If yes, can you please check if the token is getting passed in your info API call? Please share the HAR file as well. It will help us to understand the issue better.
Sandeep
Sandeep6mo ago
Hi @Chavda Jitendra JWT Token generation should be done using ThoughtSpot APIs. You can refer to the following link for more details: ThoughtSpot API Documentation(https://developers.thoughtspot.com/docs/restV2-playground?apiResourceId=http%2Fapi-endpoints%2Fauthentication%2Fget-full-access-token). The existing API (api/rest/2.0/auth/token/full) includes a user_parameters attribute. When this attribute is selected, the JWT Token is automatically generated. There’s no need to manually specify the payload—this is handled internally by the application.
REST API v2.0 Playground
ThoughtSpot REST API v2.0 Playground

Did you find this page helpful?