Getting the error when trying to access the protected server-side api
UnauthorizedError: key must be a string or buffer
I’m doing anything complicated, following the various guides and docs here.
const jwtCheck = jwt({
secret: jwksRsa.expressJwtSecret({
cache: true,
rateLimit: true,
jwksRequestsPerMinute: 5,
jwksUri: "https://jam78.eu.auth0.com/.well-known/jwks.json"
}),
audience: 'http://localhost:3001/api/protected/random-quote',
issuer: "https://jam78.eu.auth0.com/",
algorithms: 'RS256']
});
app.use('/api/protected', jwtCheck);
app.get('/api/protected/random-quote', function(req, res) {
res.status(200).send(quoter.getRandomOne());
});
testing in node
var request = require("request");
var options = { method: 'GET',
url: 'http://localhost:3001/api/protected/random-quote',
headers: { authorization: 'Bearer eyJ0eXAiOiJKV1QiLCJhbGci..} };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
The access code does not have a valid signature when I checked on jwt.io
I’m totally new, I believe I have set everything up correctly on auth0 admin guis.
Regards