Posts tagged with mule4

I'm developing a POC for a MuleSoft API (still running locally) that would fetch leads from a form. I have created a page and form and submitted a test lead via the Leads Ad Testing Tool. I can see the test lead in the Lead Centre.

I have also created the app with Product (Facebook Login for Business), I'm not sure if this is the same as "Facebook Login" I'm seeing in other post but there are no other option for a Facebook Login.

Below are the settings in the Basic > Settings and Client OAuth settings in the Facebook Login for Business > Settings menu.

[Basic > Settings] (https://i.sstatic.net/JBs5NK2C.png) Client OAuth settings

Below is the XML Code with Request Config:

<?xml version="1.0" encoding="UTF-8"?> <mule xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:oauth="http://www.mulesoft.org/schema/mule/oauth"     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:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="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/oauth http://www.mulesoft.org/schema/mule/oauth/current/mule-oauth.xsd http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd">     <http:request-config name="HTTP_Request_configuration_client_credentials" doc:name="HTTP Request configuration" doc:id="b4a82eca-5bb9-4333-a8ea-7599b9307a51" >         <http:request-connection protocol="HTTPS" host="graph.facebook.com">             <http:authentication >                 <oauth:client-credentials-grant-type clientId="xxxx" clientSecret="xxxx" scopes="public_profile,email,pages_show_list,pages_read_engagement,pages_manage_metadata,leads_retrieval" tokenUrl="https://graph.facebook.com/v20.0/oauth/access_token" />             </http:authentication>         </http:request-connection>     </http:request-config>     <http:request-config name="HTTP_Request_configuration1" doc:name="HTTP Request configuration" doc:id="826fbda6-7cf0-49b6-a153-6467b9f190c3" >         <http:request-connection protocol="HTTPS" host="graph.facebook.com" >             <http:authentication >                 <oauth:authorization-code-grant-type externalCallbackUrl="http://localhost:8081/oauth2callback" localAuthorizationUrl="http://localhost:8081/oauth/authorize" authorizationUrl="https://graph.facebook.com/oauth/authorize" clientId="xxxx" clientSecret="xxxx" scopes="public_profile,email,pages_show_list,pages_read_engagement,pages_manage_metadata,leads_retrieval" tokenUrl="https://graph.facebook.com/v20.0/oauth/access_token" localCallbackConfig="asg-facebook-poc-api-httpListenerConfig" localCallbackConfigPath="/oauth2callback"/>             </http:authentication>         </http:request-connection>     </http:request-config>          <sub-flow name="fetch-leads-subflow" doc:id="b497fa90-1bcb-4321-a419-8311eb69fdbd" >         <http:request method="GET" doc:name="Request" doc:id="c84c143f-1dc1-47f3-868a-8dc7d7685d98" config-ref="HTTP_Request_configuration1" path="/v20.0/me"/>         <ee:transform doc:name="Transform Message" doc:id="6419b680-f8fd-44db-9305-00cea610913b" >             <ee:message >                 <ee:set-payload ><![CDATA[%dw 2.0 output application/json --- payload]]></ee:set-payload>             </ee:message>         </ee:transform>         <logger level="INFO" doc:name="Logger" doc:id="b8e4609e-12a2-4f2b-9600-f6fee13736a8" message="#[payload]"/>     </sub-flow> </mule> 

Error I receive, when I tried accessing the simple endpoint in Facebook /me: ERROR

ERROR 2024-09-25 20:48:13,112 [[MuleRuntime].uber.07: [asg-facebook-poc-api].get:\fetch-leads:asg-facebook-poc-api-config.CPU_LITE @5d699551] [processor: fetch-leads-subflow/processors/0; event: 69e982e0-7b3c-11ef-8d30-9009df41381d] org.mule.runtime.core.privileged.exception.DefaultExceptionListener:  ******************************************************************************** Message               : No access token found. Verify that you have authenticated before trying to execute an operation to the API. Element               : fetch-leads-subflow/processors/0 @ asg-facebook-poc-api:scheduler-fetch-leads.xml:85 (Request) Element DSL           : <http:request method="GET" doc:name="Request" doc:id="c84c143f-1dc1-47f3-868a-8dc7d7685d98" config-ref="HTTP_Request_configuration1" path="/v20.0/me"></http:request> Error type            : HTTP:SECURITY FlowStack             : at fetch-leads-subflow(fetch-leads-subflow/processors/0 @ asg-facebook-poc-api:scheduler-fetch-leads.xml:85 (Request)) at get:\fetch-leads:asg-facebook-poc-api-config(get:\fetch-leads:asg-facebook-poc-api-config/processors/1 @ asg-facebook-poc-api:asg-facebook-poc-api.xml:202 (fetch-leads-subflow)) at asg-facebook-poc-api-main(asg-facebook-poc-api-main/processors/0 @ asg-facebook-poc-api:asg-facebook-poc-api.xml:13)   (set debug level logging or '-Dmule.verbose.exceptions=true' for everything) ******************************************************************************** 


I also tried in Postman using http://localhost:8081/oauth/authorize, logged in and it worked.

I tried the other option client credentials grant type but it requires the access token which I don't have in the first place. Did not work on this.