Cube.js:令牌无效
Cube.js: invalid token
在cubejs的服务器中,我通过cubejs token -e "180 day"
生成了一个token。
然后我赋值给.env
中的CUBEJS_API_SECRET
;并将其分配给 const cubejsApi = cubejs(...
。然后启动后端和前端,出现以下错误:
Invalid Token: {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1ODg5MzQyOTYsImV4cCI6MTYwNDQ4NjI5Nn0.RVdHlpfubXDgwG1FRYbUm-UDLVBjnb-HSVTK5bEy-ZU"
}
JsonWebTokenError: invalid signature
at /Users/chengtie/Downloads/tmp20200414/cubejs/node_modules/jsonwebtoken/verify.js:133:19
at getSecret (/Users/chengtie/Downloads/tmp20200414/cubejs/node_modules/jsonwebtoken/verify.js:90:14)
at Object.module.exports [as verify] (/Users/chengtie/Downloads/tmp20200414/cubejs/node_modules/jsonwebtoken/verify.js:94:10)
at ApiGateway.defaultCheckAuth (/Users/chengtie/Downloads/tmp20200414/cubejs/node_modules/@cubejs-backend/api-gateway/index.js:551:28)
at ApiGateway.checkAuth (/Users/chengtie/Downloads/tmp20200414/cubejs/node_modules/@cubejs-backend/api-gateway/index.js:572:18)
at Layer.handle [as handle_request] (/Users/chengtie/Downloads/tmp20200414/cubejs/node_modules/express/lib/router/layer.js:95:5)
at next (/Users/chengtie/Downloads/tmp20200414/cubejs/node_modules/express/lib/router/route.js:137:13)
at Route.dispatch (/Users/chengtie/Downloads/tmp20200414/cubejs/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/Users/chengtie/Downloads/tmp20200414/cubejs/node_modules/express/lib/router/layer.js:95:5)
at /Users/chengtie/Downloads/tmp20200414/cubejs/node_modules/express/lib/router/index.js:281:22
不管这个错误,看起来数据查询成功了。有谁知道发生了什么事吗?
CUBEJS_API_SECRET
是在创建Cube.js项目时默认生成的。除非你想重新定义它,否则你不需要在 .env
文件中分配它。您应该只将它传递给客户端的 cubejs()
。请参阅 https://cube.dev/docs/security#generating-token。
在cubejs的服务器中,我通过cubejs token -e "180 day"
生成了一个token。
然后我赋值给.env
中的CUBEJS_API_SECRET
;并将其分配给 const cubejsApi = cubejs(...
。然后启动后端和前端,出现以下错误:
Invalid Token: {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1ODg5MzQyOTYsImV4cCI6MTYwNDQ4NjI5Nn0.RVdHlpfubXDgwG1FRYbUm-UDLVBjnb-HSVTK5bEy-ZU"
}
JsonWebTokenError: invalid signature
at /Users/chengtie/Downloads/tmp20200414/cubejs/node_modules/jsonwebtoken/verify.js:133:19
at getSecret (/Users/chengtie/Downloads/tmp20200414/cubejs/node_modules/jsonwebtoken/verify.js:90:14)
at Object.module.exports [as verify] (/Users/chengtie/Downloads/tmp20200414/cubejs/node_modules/jsonwebtoken/verify.js:94:10)
at ApiGateway.defaultCheckAuth (/Users/chengtie/Downloads/tmp20200414/cubejs/node_modules/@cubejs-backend/api-gateway/index.js:551:28)
at ApiGateway.checkAuth (/Users/chengtie/Downloads/tmp20200414/cubejs/node_modules/@cubejs-backend/api-gateway/index.js:572:18)
at Layer.handle [as handle_request] (/Users/chengtie/Downloads/tmp20200414/cubejs/node_modules/express/lib/router/layer.js:95:5)
at next (/Users/chengtie/Downloads/tmp20200414/cubejs/node_modules/express/lib/router/route.js:137:13)
at Route.dispatch (/Users/chengtie/Downloads/tmp20200414/cubejs/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/Users/chengtie/Downloads/tmp20200414/cubejs/node_modules/express/lib/router/layer.js:95:5)
at /Users/chengtie/Downloads/tmp20200414/cubejs/node_modules/express/lib/router/index.js:281:22
不管这个错误,看起来数据查询成功了。有谁知道发生了什么事吗?
CUBEJS_API_SECRET
是在创建Cube.js项目时默认生成的。除非你想重新定义它,否则你不需要在 .env
文件中分配它。您应该只将它传递给客户端的 cubejs()
。请参阅 https://cube.dev/docs/security#generating-token。