How to login using Github, Facebook, Gmail and Twitter in Laravel 5.1?

Well the very first thing that I assume is that you have ran php artisan migrate(And that may be your main problem).

Next the problem that you have while storing data to database, do you have a working connection to your database from that Class \App\User? If you have named it something different I request you to change that part after the first \App\[YourClassName].

Alright if that’s working properly, you might have problem with getting data back. Just try doing somewhat like this in some different route:

<?php
    //Routes.php

    Route::get('trygithub', function(){
        $user = Socialize::with('github')->user()
        dd($user);
    });

And if you get some output on the screen, well that’s OK. If you do not get anything, try to check your github configurations.

And yeah just one more thing… Still if you do not get desired output, try to comment below. But I am pretty much sure that this ones will definitely work.

Update-1 answer:

If you want to attempt login for your user, and you are using any social profile like let’s say FB, you need to go like this:
https://maxoffsky.com/word/wp-content/uploads/2013/08/Social-Logon.png

And that’s not just one case of FB, you get some specific codes like in Google, you get one refresh token code and in twitter a permanent access token and secret. So just try to go like that. Or, have one specific term as a password for your user. str_random() may be helpful in that way and I strongly recommend that instead of these two.

Update-2 answer:

I do not recommend going through this because you will not get anything by reinventing the wheel. But still if you want to go through that nasty process, here‘s the link.

http://laravel.com/docs/5.1/authentication#adding-custom-authentication-drivers

Leave a Comment