Authentication
Authentication can be done in two ways.
API Key
API Key + JWT Signing
import (
"github.com/golang-jwt/jwt/v5"
)
func GenerateSignature(apiKey, jwtKey string) (string, error) {
claims := jwt.MapClaims{}
claims["key"] = apiKey
claims["exp"] = time.Now().Add(time.Second * 15).Unix() // this prevents replay attacks
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
tokenString, err := token.SignedString([]byte(jwtKey))
if err != nil {
return "", err
}
return tokenString, nil
}const jwt = require('jsonwebtoken');
function generateSignature(apiKey, jwtKey) {
const claims = {
key: apiKey,
// Set expiration to 15 seconds from now to prevent replay attacks
exp: Math.floor(Date.now() / 1000) + 15,
};
try {
const tokenString = jwt.sign(claims, jwtKey, { algorithm: 'HS256' });
return tokenString;
} catch (err) {
throw err;
}
}
Organizations
Header
Description
Last updated

