无法使用 WSO2 apictl 工具登录环境

Cannot login to an environment using WSO2 apictl tool

我正在使用 WSO2 API Controller 3.1.4 和 API Manager 3.1.0。 首先我使用下面的命令添加了一个环境并成功添加。

rocky@ProBook-450-G5:/data/wso2-products/apictl-3.1.4-linux-x64/apictl$./apictl add-env -e test \
> --apim https://localhost:9443 \
> --registration https://localhost:9443/client-registration/v0.16/register \
> --token https://localhost:8243/token

Successfully added environment 'test'

然后我尝试使用以下命令登录上面创建的测试环境。

rocky@ProBook-450-G5:/data/wso2-products/apictl-3.1.4-linux-x64/apictl$ ./apictl login test -u admin -p admin -k --verbose

对于上述命令,我收到以下错误响应消息。

Executed ImportExportCLI (apictl) on Wed, 19 Aug 2020 09:49:15 +0530
[INFO]: Insecure: trueSuccessfully added environment 'test'
Warning: Using --password in CLI is not secure. Use --password-stdin
Getting ClientID, ClientSecret: Status - 404 
Error: %!s(<nil>)
Body: 
Error occurred while login :  Request didn't respond 200 OK: 404 

当我在 REST-API 中尝试客户端注册时,我得到了成功的 200 响应。

我创建环境的命令有问题吗?

您应该根据文档[1]添加如下环境。

./apictl add-env -e test \
     --apim https://localhost:9443 \
     --registration https://localhost:9443 \
     --token https://localhost:8243/token

您应该将注册端点指定为 https://localhost:9443/client-registration/v0.16/register。这是旧版本 (APIM 3.0.0 + APICTL 3.0.x [2])

[1] https://apim.docs.wso2.com/en/latest/learn/api-controller/getting-started-with-wso2-api-controller/#add-an-environment

[2] https://apim.docs.wso2.com/en/3.0.0/learn/api-controller/getting-started-with-wso2-api-controller/#add-an-environment

参考这里Demo of the above correct use case(请确保在再次添加环境之前使用“./apictl remove env test”删除环境)