fisco bcos 调用接口报错WeBASE-Node-Manager user not logged in

问题:

https://webasedoc.readthedocs.io/zh_CN/latest/docs/WeBASE-Node-Manager/interface.html#id225

 

当调用下面的接口报错。以下是官方的文档。

新增私钥用户

11.1.1 传输协议规范

  • 网络传输协议:使用HTTP协议
  • 请求地址:/user/userInfo
  • 请求方式:POST
  • 请求头:Content-type: application/json
  • 返回格式:JSON

11.1.2 请求参数

1)入参表

序号

输入参数

类型

可为空

备注

1

userName

string

用户名称

2

description

string

备注

3

groupId

Int

所属群组

2)入参示例

http://127.0.0.1:5001//WeBASE-Node-Manager/user/userInfo

{ "groupId": "300001", "description": "密钥拥有者", "userName": "user1" }

11.1.3 返回参数

1)出参表

序号

输出参数

类型

 

备注

1

code

Int

返回码,0:成功 其它:失败

2

message

String

描述

3

data

object

返回信息实体(成功时不为空)

3.1

userId

int

用户编号

3.2

userName

string

用户名称

3.3

groupId

int

所属群组编号

3.4

description

String

备注

3.5

userStatus

int

状态(1-正常 2-停用) 默认1

3.6

publicKey

String

公钥信息

3.7

address

String

在链上位置的hash

3.8

hasPk

Int

是否拥有私钥信息(1-拥有,2-不拥有)

3.9

createTime

LocalDateTime

创建时间

3.10

modifyTime

LocalDateTime

修改时间

2)出参示例

  • 成功:

{ "code": 0, "message": "success", "data": { "userId": 700007, "userName": "asdfvw", "groupId": 300001, "publicKey": "0x4189fdacff55fb99172e015e1adc360777bee6682fcc975238aabf144fbf610a3057fd4b5", "userStatus": 1, "userType": 1, "address": "0x40ec3c20b5178401ae14ad8ce9c9f94fa5ebb86a", "hasPk": 1, "description": "sda", "createTime": "2019-03-15 18:00:27", "modifyTime": "2019-03-15 18:00:27" } }

  • 失败:

{ "code": 102000, "message": "system exception", "data": {} }

 

 

 

我们正常调用发现报错:

 

{

"code": 202014,

"message": "user already exists",

"data": null

}

 

 

解决方案:

抓取webase登录的包如下:

POST http://192.168.119.129:5000/mgr/WeBASE-Node-Manager/account/login?checkCode=ypqw HTTP/1.1

Host: 192.168.119.129:5000

Connection: keep-alive

Content-Length: 89

Accept: application/json, text/plain, */*

Origin: http://192.168.119.129:5000

X-Requested-With: XMLHttpRequest

User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36

token: 6604a4b3e9268978d26eb9fef16401d34f3cc25e985f4967dd2f06d12c21eb65

Content-Type: application/x-www-form-urlencoded

Referer: http://192.168.119.129:5000/

Accept-Encoding: gzip, deflate

Accept-Language: zh-CN,zh;q=0.9

Cookie: __guid=52830440.4353789523233634000.1599636751383.38; monitor_count=5

 

account=admin&accountPwd=5fef526bd3b7b26001f826f469250cb954299a0169a46d11ac37a263a9ab6ab5

 

 

 

HTTP/1.1 200

Server: nginx/1.14.2

Date: Wed, 09 Sep 2020 09:08:14 GMT

Content-Type: application/json;charset=UTF-8

Content-Length: 169

Connection: keep-alive

X-Content-Type-Options: nosniff

X-XSS-Protection: 1; mode=block

Cache-Control: no-cache, no-store, max-age=0, must-revalidate

Pragma: no-cache

Expires: 0

X-Frame-Options: DENY

Set-Cookie: JSESSIONID=2C7B692F335CE6BCBA8281A6F3F0AFAD; Path=/WeBASE-Node-Manager; HttpOnly

X-Frame-Options: SAMEORIGIN

 

{"code":0,"message":"success","data":{"accountStatus":2,"roleName":"admin","account":"admin","token":"fb50e4bbaa0e370692e35ea8b3d9f2da92aa03b9335b6a26be2297de12ee7619"}}

 

 

 

这里我发现有2种方式可以去调用需要登录之后的接口比如上述的接口

1.JSESSIONID=2C7B692F335CE6BCBA8281A6F3F0AFAD 把登录的这个cookie带入接口请求

2.头信息中带Authorization Token Tokenfb50e4bbaa0e370692e35ea8b3d9f2da92aa03b9335b6a26be2297de12ee7619

 

如下图所示:

fisco bcos 调用接口报错WeBASE-Node-Manager user not logged in_第1张图片

成功解决问题!

 

 

 

你可能感兴趣的:(fisco,bcos,fisco,bcos,区块链,webase)