1.通过用户名密码获取token
密码尽量不要带特殊字符,否则可能识别错误
/ # curl -X POST 'http://192.168.60.181:8848/nacos/v1/auth/login' -d 'username=nacos&password=nacos' {"accessToken":"eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJuYWNvcyIsImV4cCI6MTcxMjkyNDc5MH0.5XqJOiNZ4gBFlUciMHU68BtI-suZXErJcn62RvVESF0","tokenTtl":18000,"globalAdmin":true,"username":"nacos"}
2.使用获取的token调用接口
调用其他接口时,在url后添加参数accessToken={accessToken}
,其中{accessToken}
为登录时返回的token信息,如下面获取配置接口
curl -X GET "prod-zdbl-nacos.prod-whzd.svc.cluster.local:8848/nacos/v1/cs/configs?accessToken=eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJuYWNvcyIsImV4cCI6MTcxMjkyNDc5MH0.5XqJOiNZ4gBFlUciMHU68BtI-suZXErJcn62RvVESF0&dataId=manage-service.yml&group=FINANCE-GROUP"
#获取的服务器配置
server:
servlet:
context-path: /
undertow:
# 设置IO线程数, 它主要执行非阻塞的任务,它们会负责多个连接, 默认设置每个CPU核心一个线程
标签:调用,accessToken,nacos,接口,token,curl,鉴权 From: https://www.cnblogs.com/panwenbin-logs/p/18131441