'Laravel socialite error 404

I followed this tutorial on how to use socialite -> https://laracasts.com/series/whats-new-in-laravel-5/episodes/9

This is what I've done:

  • Added to my composer.json

    "laravel/socialite": "^2.0", "laravelcollective/html": "5.1.*@dev"

  • Added to my app.php

    providers

    Laravel\Socialite\SocialiteServiceProvider::class, Collective\Html\HtmlServiceProvider::class,

    aliases

    'Socialite' => Laravel\Socialite\Facades\Socialite::class, 'Form' => Collective\Html\FormFacade::class, 'Html' => Collective\Html\HtmlFacade::class,

  • Added to services.php

'github' => [ 'client_id' => 'myid', 'client_secret' => 'mysecret', 'redirect' => 'http://inspectorhost.app/login', ],

  • Added to routes.php

     Route::get('/', function () {
       if (Auth::check()) return 'Welcome back, ' . Auth::user()->username;
    
      return 'Hi guest. ' . link_to('login', 'Login with Github!');
         });
    
      Route::get('login', 'AuthController@login');
    
  • Created an AuthController and added

    class AuthController extends Controller { public function login(){ return \Socialite::with('github')->redirect(); } }

I'm using nginx and I set it up so it doesn't need to use the public folder to acccess the web

   root home/inspectorhost.app/public_html/public/;

So when I click on 'Login with Github', instead of sending me to Github to authorize the login, it sends me to /login and gives me a 404 error.

EDIT Now it gets interesting... when I go to http://inspectorhost.app and click in 'Login with Github' I get the error from above (404) however if I run php artisan serve and I access the app from localhost:8000 it works... so I guess it might be some misconfiguration on nginx?

Any help is appreciated.



Solution 1:[1]

Open in private window. because after first time session store in github if your github login in other tab

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Gagan Sharma