Facebook authentication with Perl - problem and resolution

Recently I've been required to look at writing a Facebook application. I don't use Facebook and have little interest in it myself. I looked around for a quick start with Perl and Facebook and came across Facebook Authentication with Perl and Facebook::Graph which looked interesting to follow and work through.

Putting aside the problems I had getting something set up on our system that allowed Facebook to post back to us I was left with the error:

"[28910] core @0.919358> [hit #2]request to /facebook/postback/ crashed: Could not fetch access token: Can't connect to graph.facebook.com:443 (certificate verify failed) at /home/martin/perl5/lib/perl5/Facebook/Graph/AccessToken/Response.pm line 26 in /home/martin/perl5/lib/perl5/Dancer/Handler.pm l. 77"

What I could not understand about this is that the PHP FaceBook example from FaceBook worked fine. After much searching around I realised openssl was not accepting the HTTPS certificate for FaceBook and the PHP example included the certificates. I copied the certificates from the PHP example and put them into a "certs" file then a simple "export HTTPS_CA_FILE=/home/martin/certs" got it working.

Hope this helps anyone else following JT Smith's excellent article.

Comments

Mozilla::CA

I suspect that you're using LWP 6, and that installing Mozilla::CA would also have solved the problem - just to document another solution :)

I already had Mozilla::CA installed

It appears I already had Mozilla::CA installed at version 20110409. I had LWP 6.02 installed also. I still get a certificate error unless I set HTTPS_CA_FILE.

Thanks for suggestion

Thanks, I'll look in to that.