0
votes

I am trying to use the Facebook connector to retrieve some user info in Mule like this:

    <facebook:config-with-oauth name="FacebookGlobal" appId="xxx" appSecret="xxx" doc:name="Facebook" scope="email,user_about_me, user_birthday, user_activities, user_groups, user_interests, user_likes">
        <facebook:oauth-callback-config domain="localhost" localPort="8000" remotePort="8000"/>     
    </facebook:config-with-oauth>
    <flow name="FacebookAuthorize" doc:name="FacebookAuthorize">
        <http:inbound-endpoint exchange-pattern="request-response"  doc:name="HTTP" host="localhost" path="auth" port="8000"/>
        <facebook:authorize config-ref="FacebookGlobal" doc:name="Authorize"/>
        <set-session-variable doc:name="Save Access Token" value="#[flowVars['OAuthAccessTokenId']]" variableName="accessTokenId"/>
    </flow>

    <flow name="FacebookFlow1" doc:name="FacebookFlow1">
        <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8000" doc:name="Callback"/>
        <facebook:get-user config-ref="FacebookGlobal" user="me" doc:name="Facebook" accessTokenId="#[sessionVars['accessTokenId']]"/>
    </flow>

The problem is that after the facebook:authorize operation in the FacebookAuthorize flow, the flow is interrupted and it goes automatically to the callback url specified in the oauth-callback-config. Therefore the OAuthAccessTokenID is never saved in the session variable and it cannot be used in the other flow. How does the Facebook Authorize operation exactly work?

Thanks.

1

1 Answers

0
votes

Session vars are only available within the scope of a single message. It looks like you have two separate calls into Mule thus generating two separate messages.

Also there is a known issue where flow and session vars are lost after the callback. The authorize message processor is intended to be called in complete isolation of any other connector operations and instead you need to return the accessTokenId as a message property from the authorize flow and explicitly send it back to any other flow for processing(as a message property for example).

See here for a similar answer: Flow Vars getting lost after Facebook Authorize in MuleStudio