To integrate facebook login onto your site,
Have you tried Catalyst::Authentication::Credential::FBConnect ?
It works and lets you access users facebook id from $c->user->session_uid as
documented

1. You need to register under http://developers.facebook.com and register a
new application. You must include the exact address you will use on the
machine for it to work ie. "http://localhost:3000/";

2. you need to configure include these onto your myapp.conf

    <Plugin::Authentication>
        default_realm   facebook
        <realms>
            <facebook>
                <credential>
                    class       FBConnect
                    api_key     my_app_key
                    secret      my_app_secret
                    app_name    my_app_name
                </credential>
            </facebook>
        </realms>
    </Plugin::Authentication>

3. you need a piece of javascript from facebook to create login button
(replace with your appId/fb_app_id as below):


sub login_facebook : Path('/loginfacebook') : Args(0) {
    my ( $self, $c ) = @_;
    my $fb_app_id = '9999999999999999';
    $c->stash( template => \<<FBLOGIN
    <p><fb:login-button autologoutlink="true"></fb:login-button></p>
    <p><fb:like></fb:like></p>

    <div id="fb-root"></div>
    <script>
      window.fbAsyncInit = function() {
        FB.init({appId: '$fb_app_id', status: true, cookie: true,
                 xfbml: true});

    FB.Event.subscribe('auth.sessionChange', function(response) {
      if (response.session) {
        // A user has logged in, and a new cookie has been saved
        window.location="/fblogin"; //redirects user to our facebook
login so we can validate him and get his user id.
      } else {
        // The user has logged out, and the cookie has been cleared
        window.location="/";
      }
    });
      };

      (function() {
        var e = document.createElement('script');
        e.type = 'text/javascript';
        e.src = document.location.protocol +
          '//connect.facebook.net/en_US/all.js';
        e.async = true;
        document.getElementById('fb-root').appendChild(e);
      }());
    </script>
FBLOGIN
);
}

4. then , i created an action  /fblogin to register facebook credentials
internally when user logs in (see in the js)

sub fbauthenticate :Path('/fblogin') :Args(0) {
    my ($self, $c) = @_;
    if ($c->authenticate()) {
        $c->log->debug($c->user->session_uid);
        $c->log->debug($c->user->session_key);
        $c->log->debug($c->user->session_expires);
        }
    $c->res->redirect('/');
}


So remember, register at the http://developer.facebook.com with the same url
your application will use, include ports if its not 80

--Hernan


On Tue, Nov 23, 2010 at 8:32 PM, Blaine Everingham <
grandmasterbla...@hotmail.com> wrote:

>  Hi,
>
> I was wondering if anyone has a simple example of using OAuth with facebook
> to allow user login, to your software.
>
> I keep getting the error "oauth_parameters_absent:scope", but
> Catalyst::Authentication::Credential::OAuth document does not outline where
> you are supposed to enter this.
>
> Thanks,
> Blaine
>
> _______________________________________________
> List: Catalyst@lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>
>
_______________________________________________
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/

Reply via email to