mulesoft / facebook-connector

Facebook Cloud Connector
Other
4 stars 9 forks source link

FacebookConnectorOAuth2Adapter fails to parse callback #7

Closed ddossot closed 12 years ago

ddossot commented 12 years ago

When FaceBook redirects to the Mule application at the end of the OAuth dance, it provides the access token and expiry time like as query parameters:

CALLBACK_URI?access_token=AAAEsgRJaLK0BAGEXDqP5soEAjz0ztMv8tBx7u3El63LstYQymr4MwwI61BF7tzmOXf1VeNDCSdRDyaUOmtApW9AZBsoRzvyAZBDluVVAZDZD&expires=5184000 

FacebookConnectorOAuth2Adapter chokes on this with the following error:

OAuth access token could not be extracted from: access_token=AAAEsgRJaLK0BAGEXDqP5soEAjz0ztMv8tBx7u3El63LstYQymr4MwwI61BF7tzmOXf1VeNDCSdRDyaUOmtApW9AZBsoRzvyAZBDluVVAZDZD&expires=5184000 (java.lang.Exception)

org.mule.module.facebook.adapters.FacebookConnectorOAuth2Adapter:316 (null)

Looking at the source code it appears that FacebookConnectorOAuth2Adapter expects a different callback, one that seems to be expected as JSON by the look at the regex patterns:

ACCESS_CODE_PATTERN = Pattern.compile("\"access_token\":\"([^&]+?)\"");
EXPIRATION_TIME_PATTERN = Pattern.compile("\"expires_in\":([^&]+?),");

Changing the patterns to the following allows the adapter to successfully extract the access code and expiration:

ACCESS_CODE_PATTERN = Pattern.compile("access_token=([^&]+?)&");
EXPIRATION_TIME_PATTERN = Pattern.compile("expires_in=([^&]+?)$");
federecio commented 12 years ago

Can you re test with the latest snapshot?

alejandroschenzle commented 12 years ago

Fixed