WSO2 API Manager TryIt功能null键

时间:2014-09-16 13:05:16

标签: wso2 wso2esb wso2-am wso2developerstudio

我正在使用WSO2 API管理器,并且我已经在WSO2 ESB中添加了一个API,并且在尝试使用TryIt功能时,我在控制台日志中收到以下错误。< / p>

  

[2014-09-16 13:59:26,614]错误 - APIAuthenticationHandler API身份验证失败   org.wso2.carbon.apimgt.gateway.handlers.security.APISecurityException:API访问失败:/ Sub,版本:v1.0.0,密钥:null       在org.wso2.carbon.apimgt.gateway.handlers.security.oauth.OAuthAuthenticator.authenticate(OAuthAuthenticator.java:157)       在org.wso2.carbon.apimgt.gateway.handlers.security.APIAuthenticationHandler.handleRequest(APIAuthenticationHandler.java:92)       在org.apache.synapse.rest.API.process(API.java:285)       在org.apache.synapse.rest.RESTRequestHandler.dispatchToAPI(RESTRequestHandler.java:83)       在org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:64)       在org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:220)       在org.apache.synapse.core.axis2.SynapseMessageReceiver.receive(SynapseMessageReceiver.java:83)       在org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)       at org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:344)       在org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:168)       在org.apache.axis2.transport.base.threads.NativeWorkerPool $ 1.run(NativeWorkerPool.java:172)       at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)       at java.util.concurrent.ThreadPoolExecutor $ Worker.run(Unknown Source)       在java.lang.Thread.run(未知来源)

我尝试发送GET请求,此API没有参数,在我已输入的授权字段中

Bearer XXXACCESS+TOKEN+GOES+HEREXXXX 

从高级REST客户端或商店中的REST客户端进行测试时,它可以正常运行。我已经更改了各种文件中的端口号(授权,登录,令牌,撤销)以匹配我的端口偏移量,我还在api-manager.xml中配置了我的API存储地址。

1 个答案:

答案 0 :(得分:1)

当您将该特定资源添加到API时,请同时选择“OPTIONS”动词。否则会出现此错误。

enter image description here

另外,检查/ etc / hosts条目是否将“localhost”指向“127.0.0.1”而不是计算机的IP地址。在这种情况下,请打开

    {API-M installation DIR}/repository/conf/api-manager.xml

并且,通过添加您的IP地址(或主机名)来适当修改与Swagger相关的部分

从此,

    <!--Configuration to enable/disable sending CORS headers from the Gateway-->
    <Enabled>true</Enabled>

    <!--The value of the Access-Control-Allow-Origin header. Default values are 
        API Store addresses, which is needed for swagger to function.-->
    <Access-Control-Allow-Origin>https://localhost:9443,http://localhost:9763</Access-Control-Allow-Origin>

    <!--Configure Access-Control-Allow-Headers-->
    <Access-Control-Allow-Headers>authorization,Access-Control-Allow-Origin,Content-Type</Access-Control-Allow-Headers>

</CORSConfiguration>

到此(改为添加您自己的服务器IP),

    <!--Configuration to enable/disable sending CORS headers from the Gateway-->
    <Enabled>true</Enabled>

    <!--The value of the Access-Control-Allow-Origin header. Default values are 
        API Store addresses, which is needed for swagger to function.-->
    <Access-Control-Allow-Origin>https://192.168.56.101:9443,http://192.168.56.101:9763</Access-Control-Allow-Origin>

    <!--Configure Access-Control-Allow-Headers-->
    <Access-Control-Allow-Headers>authorization,Access-Control-Allow-Origin,Content-Type</Access-Control-Allow-Headers>

</CORSConfiguration>

上面的答案假定您没有向API Manager添加任何端口偏移量。如果您这样做,您还应该相应地更改上述配置中的端口值(只需将该值添加到现有端口值)。

谢谢。

-Chathura