Been using this library to validate the access tokens and recently started to get a 401 error saying Failed to fetch authorization server metadata
.
Note: I have verified my issuer url and seems to be good.
AggregateError:
at internalConnectMultiple (node:net:1114:18)
at internalConnectMultiple (node:net:1177:5)
at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
at listOnTimeout (node:internal/timers:575:11)
at processTimers (node:internal/timers:514:7) {
code: 'ETIMEDOUT',
[errors]: [
Error: connect ETIMEDOUT 104.19.167.24:443
at createConnectionError (node:net:1634:14)
at Timeout.internalConnectMultipleTimeout (node:net:1685:38)
at listOnTimeout (node:internal/timers:575:11)
at processTimers (node:internal/timers:514:7) {
errno: -110,
code: 'ETIMEDOUT',
syscall: 'connect',
address: '104.19.167.24',
port: 443
},
Error: connect ENETUNREACH 2606:4700::6813:a718:443 - Local (:::0)
at internalConnectMultiple (node:net:1176:40)
at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
at listOnTimeout (node:internal/timers:575:11)
at processTimers (node:internal/timers:514:7) {
errno: -101,
code: 'ENETUNREACH',
syscall: 'connect',
address: '2606:4700::6813:a718',
port: 443
},
Error: connect ETIMEDOUT 104.19.168.24:443
at createConnectionError (node:net:1634:14)
at Timeout.internalConnectMultipleTimeout (node:net:1685:38)
at listOnTimeout (node:internal/timers:575:11)
at processTimers (node:internal/timers:514:7) {
errno: -110,
code: 'ETIMEDOUT',
syscall: 'connect',
address: '104.19.168.24',
port: 443
},
Error: connect ENETUNREACH 2606:4700::6813:a818:443 - Local (:::0)
at internalConnectMultiple (node:net:1176:40)
at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
at listOnTimeout (node:internal/timers:575:11)
at processTimers (node:internal/timers:514:7) {
errno: -101,
code: 'ENETUNREACH',
syscall: 'connect',
address: '2606:4700::6813:a818',
port: 443
}
]
}
Assuming the time out (5000 ms) specified inside the fetch method is causing to fail and throw. Because when I have tried to fetch the openid configs using curl with the specific url https://{issuer_base_url}/.well-known/openid-configuration
, I was able to get the configs.
import { auth as auth0 } from 'express-oauth2-jwt-bearer';
import { promisify } from 'util';
async validateAuth0Token(req: Request, res: Response) {
const validateToken = promisify(
auth0({
issuerBaseURL: ISSUER_BASE_URL,
audience: AUDIENCE,
tokenSigningAlg: 'RS256',
}),
);
await validateToken(req, res);
}