gpt4 book ai didi

javascript - Mulesoft 项目使用react

转载 作者:行者123 更新时间:2023-12-03 03:18:44 24 4
gpt4 key购买 nike

好吧,我对整个 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] 访问它,并将作为响应提供。要在任何前端技术(react、Angular、backbone)中访问它,只需调用相应的 mule 流即可。

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

关于javascript - Mulesoft 项目使用react,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46665689/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com