Javascript Mulesoft项目将作出反应

Javascript Mulesoft项目将作出反应,javascript,xml,reactjs,mule,Javascript,Xml,Reactjs,Mule,好吧,所以我对mulesoft的事还不太熟悉。我目前正在做的是,我得到了一个mulesoft流,它首先授权我访问Linkedin,然后获取我的基本个人资料详细信息。我知道我想做的是在我的React模型中显示这些信息,我如何从我的mulesoft流中获取json结果并显示到我的React应用程序中 这是我的mulesoft流程 <?xml version="1.0" encoding="UTF-8"?> <mule xmlns:scripting="http://www.mu

好吧,所以我对mulesoft的事还不太熟悉。我目前正在做的是,我得到了一个mulesoft流,它首先授权我访问Linkedin,然后获取我的基本个人资料详细信息。我知道我想做的是在我的React模型中显示这些信息,我如何从我的mulesoft流中获取json结果并显示到我的React应用程序中

这是我的mulesoft流程

 <?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting"
    xmlns:tcp="http://www.mulesoft.org/schema/mule/tcp" xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:oauth2="http://www.mulesoft.org/schema/mule/oauth2" xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:linkedin="http://www.mulesoft.org/schema/mule/linkedin" xmlns:barn1="http://www.mulesoft.org/schema/mule/barn1" xmlns:barn="http://www.mulesoft.org/schema/mule/barn" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:spring="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/linkedin http://www.mulesoft.org/schema/mule/linkedin/current/mule-linkedin.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd
http://www.mulesoft.org/schema/mule/oauth2 http://www.mulesoft.org/schema/mule/oauth2/current/mule-oauth2.xsd
http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd
http://www.mulesoft.org/schema/mule/tcp http://www.mulesoft.org/schema/mule/tcp/current/mule-tcp.xsd">
    <http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="3000" doc:name="HTTP Listener Configuration" connectionIdleTimeout="3000000"/>
    <http:request-config name="AcceptHTTP_Request_Configuration" host="api.linkedin.com/v1/people/~?" port="403" doc:name="HTTP Request Configuration"  connectionIdleTimeout="300000000" protocol="HTTPS">
        <oauth2:authorization-code-grant-type clientId="77ii50ttcezoti" clientSecret="aifsEkcXEiMsayru" redirectionUrl="http://localhost:3000/callback">
            <oauth2:authorization-request authorizationUrl="https://www.linkedin.com/oauth/v2/authorization?response_type=code&amp;state=987654321" localAuthorizationUrl="http://localhost:3000/authorize"/>
            <oauth2:token-request tokenUrl="http://linkedin.com/oauth/v2/accessToken" >
                <oauth2:token-response >
                    <oauth2:custom-parameter-extractor paramName="token_1" value="#[json:token_type]"/>
                </oauth2:token-response>
            </oauth2:token-request>
        </oauth2:authorization-code-grant-type>
    </http:request-config>
    <http:request-config name="HTTP_Request_Configuration" host="api.linkedin.com" port="8081" doc:name="HTTP Request Configuration"/>
    <oauth2:token-manager-config name="Token_Manager_Config" doc:name="Token Manager Config"/>
    <flow name="testingFlow">
        <http:listener config-ref="HTTP_Listener_Configuration" path="/linkedin" doc:name="authorize" allowedMethods="GET"/>
        <http:request config-ref="AcceptHTTP_Request_Configuration" path="/" method="GET" doc:name="getaccesstoken"/>
        <json:xml-to-json-transformer doc:name="XML to JSON"/>
    </flow>
</mule>

据我所知,您已获得linkedin个人资料信息。 现在在mule中,信息将作为有效负载提供,您可以通过[payload]访问它,并作为响应提供。要在任何前端技术中访问这一点,只需调用相应的mule流即可


在您的情况下:localhost:3000/linkedin调用为GET

您需要将您的配置文件信息作为有效负载返回到Mule API,然后您需要使用postman测试您的API


如果每个想法都很有效,您需要使用前端技术创建相同的请求React、Angular、VueJs…

小心:您正在共享您的clientId和clientSecret,这两个敏感信息允许您在LinkedIn中进行身份验证