JWT Token Generation
Ive tried the jwe/jws encoding options xano has but none seem to create a token that works for the external api authentication im trying to connect.
The only thing that has worked is a NodeJS libary 'jwt-simple'.
function(properties, context) {const jwt = require('jwt-simple');
const moment = require('moment');const payload = {
clientId: properties.clientId,
timestamp: moment().unix()
};const clientSecret = properties.clientSecret;
const token = jwt.encode(payload, clientSecret, 'HS256', {});
return {token: token}}
simple enough but cant recreate this in xano.
Ive also looked at the lambda functions and looked through the Crypto library documentations but am not sure what function to use.. im not a JS dev.
Can xano add the 'jwt-simple' library to the lambda libraries ?
Answers
-
hi @tom94 - I notice you don't have any value that you are encoding. Is this intentional?
Have you seen the JWE and JSW encode examples from the documentation? These might help (https://docs.xano.com/working-with-data/functions/security#examples)
-
Hey @Michael Udinski, I tried again with the ClientId in the value instead of the header but still not luck.
-
We ended using lambda: jose library to create the tokens 👍️
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback