johnnncodes / laravelsnippets

LaravelSnippets.com website | A repository of useful code snippets for Laravel PHP framework. Submit, grab and share!
http://laravelsnippets.com/
333 stars 97 forks source link

Facebook and Google integration #85

Closed michaellouieloria closed 9 years ago

michaellouieloria commented 10 years ago

sample hybridauth.php to be included in app\config

<?php

return array(
    'base_url'  => URL::route('hybridauth', array('process' => true)),
    'providers' => array(
        'Facebook' => array(
            'enabled' => true,
            'keys' => array(
                'id' => '',
                'secret' => ''
            ),
            'scope' => ['user_about_me', 'email']
        ),
        'Google' => array(
            'enabled' => true,
            'keys' => array(
                'id' => '',
                'secret' => ''
            ),
            'access_type' => 'online',
            'scope' => 'https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email'
        )
    )
);
ghost commented 10 years ago

Awesome! Thank you!

johnnncodes commented 10 years ago

Nice! Thanks @michaellouieloria! :)

Will try to test this locally tomorrow when I get the chance. Cheers!

davidnknight commented 10 years ago

Hi @michaellouieloria,

Firstly, apologies that it has taken this long to look at this PR.

I have been testing your code locally and I can't seem to get it working. I have migrated the database, created the config file and added Facebook app credentials for the purpose of testing but when I click 'Login with Facebook' on the login page, all I'm seeing is "Authentication failed" with no further error output.

If you could please get back to me with additional information, I'd be happy to work with you and continue to test so that we can get closer to merging this. Thanks!

ghost commented 10 years ago

Remove the trailing slash from the link and it will work.

Il domenica 23 marzo 2014, davidnknight notifications@github.com ha scritto:

Hi @michaellouieloria https://github.com/michaellouieloria,

Firstly, apologies that it has taken this long to look at this PR.

I have been testing your code locally and I can't seem to get it working. I have migrated the database, created the config file and added Facebook app credentials for the purpose of testing but when I click 'Login with Facebook' on the login page, all I'm seeing is "Authentication failed" with no further error output.

If you could please get back to me with additional information, I'd be happy to work with you and continue to test so that we can get closer to merging this. Thanks!

— Reply to this email directly or view it on GitHubhttps://github.com/basco-johnkevin/laravelsnippets/pull/85#issuecomment-38398400 .

Best regards,

Ionut Tanasa tanasa.it http://www.tanasa.it @ionutz2k https://twitter.com/ionutz2k

ghost commented 10 years ago

Remove '/' from AuthController @ line 105.

davidnknight commented 10 years ago

Didn't work.

$config['base_url'] = URL::route('hybridauth', array('provider' => $provider, 'process' => true)) . '/';

Changed to:

$config['base_url'] = URL::route('hybridauth', array('provider' => $provider, 'process' => true));

michaellouieloria commented 10 years ago

What's your Site URL in facebook app settings?

davidnknight commented 10 years ago

I'm testing locally so haven't set one but I'm not even getting that far.

The exception thrown is: Undefined index: providers on line 284 of app/vendor/hybridauth/hybridauth/hybridauth/Hybrid/Provider_Adapter.php.

As said earlier, I copied your config file, added the app key and secret and 'providers' certainly exists in the config file.

michaellouieloria commented 10 years ago

maybe you can fork and create a branch so I can pull it

ghost commented 10 years ago

When I tried it, a while ago. it worked. I read a bit online that the problem was the trailing slash.

I replicated the code in one of my personal projects and what @michaellouieloria did worked just fine.