简体   繁体   English

如何为 WSO2 API Manager 的获取令牌添加中介?

[英]how to add mediation for get token of WSO2 API Manager?

I Have This API And I Used the Message Mediation Below to Authenticate and Get the Token:我有这个 API,我使用下面的消息中介来验证和获取令牌:

curl -X POST "URL" -H "accept: / " -H "Content-Type: application/x-www-form-urlencoded" -d "username=user&password=password" curl -X POST "URL" -H​​ "accept: / " -H "Content-Type: application/x-www-form-urlencoded" -d "username=user&password=password"

result is: enter image description here结果是:在此处输入图像描述

<payloadFactory media-type="x-www-form-urlencoded">
    <format>
        {
        "username":"user",
        "password":"password"
        }
    </format>
    <args>
        
    </args>
</payloadFactory>

 <header name="Content-Type" value="application/x-www-form-urlencoded" scope="transport" />
<property name="messageType" value="application/json" scope="axis2" type="STRING" />
<property name="REST_URL_POSTFIX" value="" scope="axis2" type="STRING" />

<call blocking="true">
    <endpoint>
        <http method="POST" uri-template="URL" />
    </endpoint>
</call>


<property name="bearer-token" expression="json-eval($..token)" scope="default" type="STRING" />
<property name="REST_URL_POSTFIX" expression="get-property('resource')" scope="axis2" type="STRING" />
<header name="Authorization" expression="fn:concat('Bearer ', get-property('bearer-token'))" scope="transport" />
<payloadFactory media-type="x-www-form-urlencoded">
    <format>$1</format>
    <args>
       <arg evaluator="xml" expression="get-property('request-body')" />
    </args>
</payloadFactory>

But i have this error: enter image description here但我有这个错误:在此处输入图像描述

WSO2 API Manager Logs WSO2 API 管理器日志

INFO - LogMediator STATUS = Message dispatched to the main sequence. INFO - LogMediator STATUS = 发送到主序列的消息。 Invalid URL., RESOURCE = url, HEALTH CHECK URL = url [2021-07-28 16:22:39,696] INFO - LogMediator STATUS = Message dispatched to the main sequence.无效的 URL., RESOURCE = url, HEALTH CHECK URL = url [2021-07-28 16:22:39,696] INFO - LogMediator STATUS = 消息发送到主序列。 Invalid URL., RESOURCE = url, HEALTH CHECK URL = url无效的 URL。,资源 = url,健康检查 URL = url

Make sure that, you have provided the correct token endpoint url for the Call mediator确保您已为呼叫调解器提供了正确的令牌端点 URL

<call blocking="true">
    <endpoint>
        <http method="POST" uri-template="https://your-token-endpoint/oauth" />
    </endpoint>
</call>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM