dba
dba

Reputation: 240

Flow Vars getting lost after Facebook Authorize in MuleStudio

I have a simple Flow to authorize to Facebook and then to post a Message.

<flow name="drupal-esbFlow2" doc:name="drupal-esbFlow2">
    <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8082" doc:name="HTTP"/>
    <set-variable variableName="facebookMSG" value="#[message.inboundProperties['msg']]" doc:name="Variable"/>
    <facebook:authorize config-ref="Facebook" doc:name="Authorize"/>
    <set-session-variable variableName="accessTokenId" value="#[flowVars['OAuthAccessTokenId']]" doc:name="Get OAuthAccessTokenId"/>
    <facebook:publish-message config-ref="Facebook" msg="#[flowVars['facebookMSG']]" profile_id="100001574667695" accessTokenId="#[sessionVars['accessTokenId']]" doc:name="Publish Message"/>
    <json:object-to-json-transformer doc:name="Object to JSON"/>
</flow>

The Idea is that i want to hit the endpoint localhost:8082?msg=myMessage. Then i want to safe the inboundProperties['msg'] in a Flow Variable and use this in the Facebook Connector. But it seems that the Variables gets lost in the Transport...

I have read that this is an known issue (mule facebook - flow variable), but is there no walk around or something?

Upvotes: 2

Views: 881

Answers (1)

Ryan Carter
Ryan Carter

Reputation: 11606

Well as the answer sort of alludes to, it seems the authorize mp is intended to be called in complete isolation of any other logic and simply return the access token id via an http:response-builder. The client is then responsible for sending the access token id to another flow for any other processing:

<flow name="authorizationAndAuthenticationFlow">
    <http:inbound-endpoint host="localhost" port="8080" path="oauth-authorize"/>
    <facebook:authorize/>
    <http:response-builder status="200">
        <http:set-cookie name="accessTokenId" value="#[flowVars['OAuthAccessTokenId']]"/>
        <set-payload value="You have successfully authorized the connector. You access token id is #[flowVars['OAuthAccessTokenId']]"/>
    </http:response-builder>
</flow>

I can sort of see why, but makes you architect your app in a very specific way.

The other options is to use the "state" parameter. But this depends on on what types of data you're in your flow vars. Example:

<facebook:authorize state="#[flowVars.myvalue]"/> 

This will then get returned in the callback as an inbound property that can be retrieved via:

#[message.inboundProperties['state']] 

etc.

Alternatively you could look at persisting certain values, possibly in the mule object-store.

Upvotes: 2

Related Questions