开源改变世界

API 信息/问题 #663

推推 grbl 2年前 (2023-02-03) 311次浏览
关闭
12 个任务中的第 4 个
ToxicDeathX 打开了这个问题 2020 年 11 月 30 日 · 2 条评论
关闭
12 个任务中的第 4 个

API 信息/问题#663

ToxicDeathX 打开了这个问题 2020 年 11 月 30 日 · 2 条评论

注释

API 信息/问题 #663
毒死X 评论了 2020 年 11 月 30 日  

描述

无法使用 URL http://192.168.1.xxx/api/signin访问 CNCJS 中的 API 系统。

它一直在说 401 或 403,具体取决于 API 尝试查询的内容,并且用户是在settings->user-accounts中分配的,如果没有定义用户,我可以访问 /api/signin 但不能做任何进一步的事情-更多API 系统是否有适当的文档,或者如何访问https://github.com/cncjs/cncjs/wiki/Server-API#authorized-access-only-endpoints

我尝试在对 CNCJS 服务器的发布请求中使用以下字符串:

{"enabled":true,"token":"token-was-here","name":"user-was-here"}

{ enabled: true, token: <JWT>, name, <name> }
我使用的工具是 Firefox 上的 RESTClient。

2020-11-29T18:57:16.191Z - warn app { JsonWebTokenError: jwt must be provided at Object.module.exports [as verify] (/usr/local/lib/node_modules/cncjs/node_modules/jsonwebtoken/verify.js:53:17) at _callee2$ (/usr/local/lib/node_modules/cncjs/dist/cncjs/server/index.js:4273:77) at tryCatch (/usr/local/lib/node_modules/cncjs/node_modules/regenerator-runtime/runtime.js:63:40) at Generator.invoke [as _invoke] (/usr/local/lib/node_modules/cncjs/node_modules/regenerator-runtime/runtime.js:293:22) at Generator.next (/usr/local/lib/node_modules/cncjs/node_modules/regenerator-runtime/runtime.js:118:21) at asyncGeneratorStep (/usr/local/lib/node_modules/cncjs/dist/cncjs/server/index.js:4022:103) at _next (/usr/local/lib/node_modules/cncjs/dist/cncjs/server/index.js:4024:194) at /usr/local/lib/node_modules/cncjs/dist/cncjs/server/index.js:4024:364 at new Promise (<anonymous>) at /usr/local/lib/node_modules/cncjs/dist/cncjs/server/index.js:4024:97 at /usr/local/lib/node_modules/cncjs/dist/cncjs/server/index.js:4310:22 at Layer.handle_error (/usr/local/lib/node_modules/cncjs/node_modules/express/lib/router/layer.js:71:5) at trim_prefix (/usr/local/lib/node_modules/cncjs/node_modules/express/lib/router/index.js:315:13) at /usr/local/lib/node_modules/cncjs/node_modules/express/lib/router/index.js:284:7 at Function.process_params (/usr/local/lib/node_modules/cncjs/node_modules/express/lib/router/index.js:335:12) at next (/usr/local/lib/node_modules/cncjs/node_modules/express/lib/router/index.js:275:10) name: 'JsonWebTokenError', message: 'jwt must be provided' } 2020-11-29T18:57:16.202Z - warn app Forbidden: ipaddr=192.168.1.xxx, code="credentials_required", message="No authorization token was found"

版本

  • CNCjs:1.9.22
  • Node.js:V10.21.0
  • NPM:6.14.9

你如何安装CNCjs?

  • NPM
  • 下载 CNCjs 桌面应用程序

数控系统

  • Grbl
  • 冰沙
  • TinyG/g2核心

硬件

  • 树莓派
  • 台式机或笔记本电脑
  • 移动设备

操作系统

  • 不适用
  • 视窗
  • 苹果
  • Linux
API 信息/问题 #663
作者
毒死X 评论了 2020 年 12 月 16 日  

最终通过深入研究代码解决了我自己的问题,但这里是需要遵循的流程,但可能不正确但有效。

脚步

1: 发布到 :8000/api/signin 正文包含表单方法:
{
token=””,
name=”USERNAME HERE”,
password=”PASSWORD HERE”
}

从 json 输出中检索令牌

2: GET on IP:8000/api/controllers 获取数据转储

3:过滤数据