【发布时间】:2019-12-23 16:30:58
【问题描述】:
我正在使用 Auth0 对我的 react 应用程序的用户进行身份验证。我一直在尝试访问服务器端的资源,但我不断收到 UnauthorizedError: jwt malformed as an Error。
我在社区论坛上关注了以下主题:https://community.auth0.com/t/unauthorizederror-jwt-malformed-in-express-js/7352 许多用户认为指南中的受众价值是错误的。指南中给出的受众是 https:///userinfo 但应该是“https://.auth0.com/api/v2/”,我已经进行了更改,但错误仍然存在。
这对某些人有效,但对我无效。 这是我一直遵循的指南:https://auth0.com/blog/react-tutorial-building-and-securing-your-first-app/
const checkJwt = jwt({
secret: jwksRsa.expressJwtSecret({
cache: true,
rateLimit: true,
jwksRequestsPerMinute: 5,
jwksUri: `https://<domain>/.well-known/jwks.json`
}),
// Validate the audience and the issuer.
audience: "https://<something>/api/v2/",
issuer: `https://<something>/`,
algorithms: ["RS256"]
});
这是我在快递方面编写的代码。
this.auth0 = new auth0.WebAuth({
// the following three lines MUST be updated
domain: "<Domain>",
audience: "https://<Something>/api/v2/",
clientID: "clientID",
redirectUri: "http://localhost:3000/callback",
responseType: "token",
scope: "openid"
});
这是写在应用前端的代码。
【问题讨论】:
标签: express authentication jwt auth0