Mule Facebook Null Payload

306 views Asked by At

Asked to evaluate buying Mulesoft - and produce demo that connects to facebook. Am following the two samples here:
https://github.com/mulesoft/facebook-connector/blob/master/doc/sample.md and http://blogs.mulesoft.com/mule-school-integration-with-social-media-part-ii-%E2%80%93-facebook/

Ran into a problem with the first sample - it wouldn't compile because the endpoint for the http connector was the same as the facebook connector. I did some research and made some changes, but I now get the error below and can't find anyone else that experienced the same:

Unable to fetch access token. Message payload is of type: NullPayload - this is on the callback page. Has anyone experienced this?

Here is my code:

    <http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8099" doc:name="HTTP Listener Configuration"/>
<facebook:config-with-oauth name="Facebook-config" consumerKey="..." consumerSecret="..." scope="user_photos" doc:name="Facebook">
    <facebook:oauth-callback-config domain="localhost" localPort="8099" remotePort="8099" path="callback"/>
</facebook:config-with-oauth>
<http:listener-config name="HTTP_Listener_Configuration1" host="localhost" port="8094" doc:name="HTTP Listener Configuration"/>
<flow name="Authorize">
    <http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
    <facebook:authorize config-ref="Facebook-config" doc:name="Facebook"/>
    <set-session-variable variableName="accessTokenID" value="#[flowVars['OAuthAccessTokenId']]" doc:name="Save Access Token"/>
    <flow-ref name="PhotoDownload" doc:name="Call Photo Download"/>
</flow>
<flow name="PhotoDownload">
    <http:listener config-ref="HTTP_Listener_Configuration1" path="/" doc:name="HTTP"/>
    <not-filter doc:name="Not">
        <wildcard-filter pattern="/favicon.ico" caseSensitive="false"/>
    </not-filter>
    <facebook:get-user-picture config-ref="Facebook-config" user="me" accessTokenId="#[sessionVars['accessTokenId']]" doc:name="Get Profile Picture"/>
    <file:outbound-endpoint path="c:\temp" outputPattern="profilepic.jpg" responseTimeout="10000" doc:name="Save The Picture "/>
    <json:object-to-json-transformer doc:name="Object to JSON"/>
</flow>

Here is the stack trace:

        
ERROR 2015-06-10 13:47:07,731 [[internalfacebook].HTTP_Listener_Configuration.worker.01] org mule exception DefaultMessagingExceptionStrategy: 
********************************************************************************
Message               : Unable to fetch access token. Message payload is of type: NullPayload
Code                  : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. unable to find valid certification path to requested target (sun.security.provider.certpath.SunCertPathBuilderException)
  sun.security.provider.certpath SunCertPathBuilder:-1 (null)
2. PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target (sun.security.validator ValidatorException)
  sun.security.validator PKIXValidator:-1 (null)
3. sun.security.validator ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target (javax net ssl SSLHandshakeException)
  sun security ssl Alerts:-1 ( java.sun com/j2ee/sdk_1.3/techdocs/api/javax/net/ssl/SSLHandshakeException html)
4. Error found while consuming http resource at https(colonslashslash) graph facebook com/oauth/access_token (java.lang.RuntimeException)
  org.mule security oauth util HttpUtilImpl:93 (null)
5. Unable to fetch access token. Message payload is of type: NullPayload (org mule api MessagingException)
  org.mule.security.oauth.processor.OAuth2FetchAccessTokenMessageProcessor:95 ( wwwmulesoftrog docs site current3 apidocs org mule api MessagingException html)
--------------------------------------------------------------------------------
Root Exception stack trace:
sun.security.provider certpath SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun security provider certpath SunCertPathBuilder engineBuild(Unknown Source)
    at java.security cert CertPathBuilder build(Unknown Source)
    at sun.security validator PKIXValidator doBuild(Unknown Source)
    + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************

INFO  2015-06-10 13:47:08,183 [[internalfacebook].HTTP_Listener_Configuration.worker.01] org mule module http internal listener HttpListenerRegistry: No listener found for request: (GET)/favicon ico
INFO  2015-06-10 13:47:08,184 [[internalfacebook].HTTP_Listener_Configuration.worker.01] org mule module http internal listener HttpListenerRegistry: Available listeners are: [(*)/callback/, (*)/]
1

There are 1 answers

0
D Sanders On

Couple things might help. First off, make sure your FB App and Mule FB Config match on the "scope" Ex. "email,public_profile,user_friends".

Also, I solved part of this issue by creating a global HTTP element as the callback. The callback HTTP path needs to be "/*". Then in the Authorization FB component under the OAuth tab, I put the callback HTTP name as the HTTP Connector Reference.

<facebook:oauth-callback-config domain="localhost"
        localPort="5000" remotePort="5000" connector-ref="callback"></facebook:oauth-callback-config>
</facebook:config-with-oauth>
<http:listener-config name="callback" host="0.0.0.0"
    port="5000" basePath="/*" doc:name="HTTP Listener Configuration" />