首页 > 解决方案 > 无法使用 WSO2 apictl 工具登录环境

问题描述

我正在使用 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 响应。

我用来创建环境的命令有什么问题吗?

标签: wso2wso2-am

解决方案


您应该根据文档 [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

请参阅此处以获取上述正确用例的演示(请确保在再次添加环境之前使用“./apictl remove env test”删除环境)


推荐阅读