Laravel Socialite Request Returns Null
up vote
0
down vote
favorite
I'm using Laravel Socialite 5.0.
<?php
use IlluminateHttpRequest;
public function login(AuthenticateUser $authenticateUser, Request $request){
return $authenticateUser->execute($request->has('code'));
}
$request->has('code')
always returns null. Why is that?
Providing my AuthenticateUser class I see this as a redirect/request problem.
<?php
namespace App;
use LaravelSocialiteContractsFactory as Socialite;
use IlluminateContractsAuthGuard as Guard;
use AppRepositoriesUserRepository as UserRepository;
use Log;
class AuthenticateUser {
private $users;
private $socialite;
private $auth;
public function __construct (UserRepository $users, Socialite $socialite, Guard $auth) {
$this->users = $users;
$this->socialite = $socialite;
$this->auth = $auth;
}
public function execute ($hasCode) {
if( ! $hasCode){
Log::info('1');
return $this->getAuthorizationFirst();
}
Log::info('2');
$user = $this->socialite->driver('github')->user();
}
public function getAuthorizationFirst(){
return $this->socialite->driver('github')->redirect();
}
}
Adding the AuthController Class for reference:
class AuthController extends Controller {
/*
|--------------------------------------------------------------------------
| Registration & Login Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users, as well as the
| authentication of existing users. By default, this controller uses
| a simple trait to add these behaviors. Why don't you explore it?
|
*/
use AuthenticatesAndRegistersUsers;
/**
* Create a new authentication controller instance.
*
* @param IlluminateContractsAuthGuard $auth
* @param IlluminateContractsAuthRegistrar $registrar
* @return void
*/
public function __construct(Guard $auth, Registrar $registrar)
{
$this->auth = $auth;
$this->registrar = $registrar;
$this->middleware('guest', ['except' => 'getLogout']);
}
public function login(AuthenticateUser $authenticateUser, Request $request){
Log::info('_'.$request->has('code').'_');
return $authenticateUser->execute($request->has('code'));
}
}
php laravel laravel-5 laravel-socialite laravel-request
|
show 5 more comments
up vote
0
down vote
favorite
I'm using Laravel Socialite 5.0.
<?php
use IlluminateHttpRequest;
public function login(AuthenticateUser $authenticateUser, Request $request){
return $authenticateUser->execute($request->has('code'));
}
$request->has('code')
always returns null. Why is that?
Providing my AuthenticateUser class I see this as a redirect/request problem.
<?php
namespace App;
use LaravelSocialiteContractsFactory as Socialite;
use IlluminateContractsAuthGuard as Guard;
use AppRepositoriesUserRepository as UserRepository;
use Log;
class AuthenticateUser {
private $users;
private $socialite;
private $auth;
public function __construct (UserRepository $users, Socialite $socialite, Guard $auth) {
$this->users = $users;
$this->socialite = $socialite;
$this->auth = $auth;
}
public function execute ($hasCode) {
if( ! $hasCode){
Log::info('1');
return $this->getAuthorizationFirst();
}
Log::info('2');
$user = $this->socialite->driver('github')->user();
}
public function getAuthorizationFirst(){
return $this->socialite->driver('github')->redirect();
}
}
Adding the AuthController Class for reference:
class AuthController extends Controller {
/*
|--------------------------------------------------------------------------
| Registration & Login Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users, as well as the
| authentication of existing users. By default, this controller uses
| a simple trait to add these behaviors. Why don't you explore it?
|
*/
use AuthenticatesAndRegistersUsers;
/**
* Create a new authentication controller instance.
*
* @param IlluminateContractsAuthGuard $auth
* @param IlluminateContractsAuthRegistrar $registrar
* @return void
*/
public function __construct(Guard $auth, Registrar $registrar)
{
$this->auth = $auth;
$this->registrar = $registrar;
$this->middleware('guest', ['except' => 'getLogout']);
}
public function login(AuthenticateUser $authenticateUser, Request $request){
Log::info('_'.$request->has('code').'_');
return $authenticateUser->execute($request->has('code'));
}
}
php laravel laravel-5 laravel-socialite laravel-request
I am following the laracast tutorial: laracasts.com/series/whats-new-in-laravel-5/episodes/9 But just not able to pass through this has('code').
– Aditya Kappagantula
Sep 11 '15 at 6:59
How does the form that triggers the function look like?
– Szenis
Sep 11 '15 at 7:07
Its not a form. I just trigger the route. <a class="btn btn-block btn-social btn-github" href={{ url('/github/auth') }}> <i class="fa fa-github"></i> Sign in with Github </a>
– Aditya Kappagantula
Sep 11 '15 at 7:12
can you post your authenticate user class?
– Szenis
Sep 11 '15 at 8:32
Done. posted code.
– Aditya Kappagantula
Sep 11 '15 at 8:35
|
show 5 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm using Laravel Socialite 5.0.
<?php
use IlluminateHttpRequest;
public function login(AuthenticateUser $authenticateUser, Request $request){
return $authenticateUser->execute($request->has('code'));
}
$request->has('code')
always returns null. Why is that?
Providing my AuthenticateUser class I see this as a redirect/request problem.
<?php
namespace App;
use LaravelSocialiteContractsFactory as Socialite;
use IlluminateContractsAuthGuard as Guard;
use AppRepositoriesUserRepository as UserRepository;
use Log;
class AuthenticateUser {
private $users;
private $socialite;
private $auth;
public function __construct (UserRepository $users, Socialite $socialite, Guard $auth) {
$this->users = $users;
$this->socialite = $socialite;
$this->auth = $auth;
}
public function execute ($hasCode) {
if( ! $hasCode){
Log::info('1');
return $this->getAuthorizationFirst();
}
Log::info('2');
$user = $this->socialite->driver('github')->user();
}
public function getAuthorizationFirst(){
return $this->socialite->driver('github')->redirect();
}
}
Adding the AuthController Class for reference:
class AuthController extends Controller {
/*
|--------------------------------------------------------------------------
| Registration & Login Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users, as well as the
| authentication of existing users. By default, this controller uses
| a simple trait to add these behaviors. Why don't you explore it?
|
*/
use AuthenticatesAndRegistersUsers;
/**
* Create a new authentication controller instance.
*
* @param IlluminateContractsAuthGuard $auth
* @param IlluminateContractsAuthRegistrar $registrar
* @return void
*/
public function __construct(Guard $auth, Registrar $registrar)
{
$this->auth = $auth;
$this->registrar = $registrar;
$this->middleware('guest', ['except' => 'getLogout']);
}
public function login(AuthenticateUser $authenticateUser, Request $request){
Log::info('_'.$request->has('code').'_');
return $authenticateUser->execute($request->has('code'));
}
}
php laravel laravel-5 laravel-socialite laravel-request
I'm using Laravel Socialite 5.0.
<?php
use IlluminateHttpRequest;
public function login(AuthenticateUser $authenticateUser, Request $request){
return $authenticateUser->execute($request->has('code'));
}
$request->has('code')
always returns null. Why is that?
Providing my AuthenticateUser class I see this as a redirect/request problem.
<?php
namespace App;
use LaravelSocialiteContractsFactory as Socialite;
use IlluminateContractsAuthGuard as Guard;
use AppRepositoriesUserRepository as UserRepository;
use Log;
class AuthenticateUser {
private $users;
private $socialite;
private $auth;
public function __construct (UserRepository $users, Socialite $socialite, Guard $auth) {
$this->users = $users;
$this->socialite = $socialite;
$this->auth = $auth;
}
public function execute ($hasCode) {
if( ! $hasCode){
Log::info('1');
return $this->getAuthorizationFirst();
}
Log::info('2');
$user = $this->socialite->driver('github')->user();
}
public function getAuthorizationFirst(){
return $this->socialite->driver('github')->redirect();
}
}
Adding the AuthController Class for reference:
class AuthController extends Controller {
/*
|--------------------------------------------------------------------------
| Registration & Login Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users, as well as the
| authentication of existing users. By default, this controller uses
| a simple trait to add these behaviors. Why don't you explore it?
|
*/
use AuthenticatesAndRegistersUsers;
/**
* Create a new authentication controller instance.
*
* @param IlluminateContractsAuthGuard $auth
* @param IlluminateContractsAuthRegistrar $registrar
* @return void
*/
public function __construct(Guard $auth, Registrar $registrar)
{
$this->auth = $auth;
$this->registrar = $registrar;
$this->middleware('guest', ['except' => 'getLogout']);
}
public function login(AuthenticateUser $authenticateUser, Request $request){
Log::info('_'.$request->has('code').'_');
return $authenticateUser->execute($request->has('code'));
}
}
php laravel laravel-5 laravel-socialite laravel-request
php laravel laravel-5 laravel-socialite laravel-request
edited Nov 11 at 9:56
Karl Hill
1,9031736
1,9031736
asked Sep 11 '15 at 6:58
Aditya Kappagantula
3611416
3611416
I am following the laracast tutorial: laracasts.com/series/whats-new-in-laravel-5/episodes/9 But just not able to pass through this has('code').
– Aditya Kappagantula
Sep 11 '15 at 6:59
How does the form that triggers the function look like?
– Szenis
Sep 11 '15 at 7:07
Its not a form. I just trigger the route. <a class="btn btn-block btn-social btn-github" href={{ url('/github/auth') }}> <i class="fa fa-github"></i> Sign in with Github </a>
– Aditya Kappagantula
Sep 11 '15 at 7:12
can you post your authenticate user class?
– Szenis
Sep 11 '15 at 8:32
Done. posted code.
– Aditya Kappagantula
Sep 11 '15 at 8:35
|
show 5 more comments
I am following the laracast tutorial: laracasts.com/series/whats-new-in-laravel-5/episodes/9 But just not able to pass through this has('code').
– Aditya Kappagantula
Sep 11 '15 at 6:59
How does the form that triggers the function look like?
– Szenis
Sep 11 '15 at 7:07
Its not a form. I just trigger the route. <a class="btn btn-block btn-social btn-github" href={{ url('/github/auth') }}> <i class="fa fa-github"></i> Sign in with Github </a>
– Aditya Kappagantula
Sep 11 '15 at 7:12
can you post your authenticate user class?
– Szenis
Sep 11 '15 at 8:32
Done. posted code.
– Aditya Kappagantula
Sep 11 '15 at 8:35
I am following the laracast tutorial: laracasts.com/series/whats-new-in-laravel-5/episodes/9 But just not able to pass through this has('code').
– Aditya Kappagantula
Sep 11 '15 at 6:59
I am following the laracast tutorial: laracasts.com/series/whats-new-in-laravel-5/episodes/9 But just not able to pass through this has('code').
– Aditya Kappagantula
Sep 11 '15 at 6:59
How does the form that triggers the function look like?
– Szenis
Sep 11 '15 at 7:07
How does the form that triggers the function look like?
– Szenis
Sep 11 '15 at 7:07
Its not a form. I just trigger the route. <a class="btn btn-block btn-social btn-github" href={{ url('/github/auth') }}> <i class="fa fa-github"></i> Sign in with Github </a>
– Aditya Kappagantula
Sep 11 '15 at 7:12
Its not a form. I just trigger the route. <a class="btn btn-block btn-social btn-github" href={{ url('/github/auth') }}> <i class="fa fa-github"></i> Sign in with Github </a>
– Aditya Kappagantula
Sep 11 '15 at 7:12
can you post your authenticate user class?
– Szenis
Sep 11 '15 at 8:32
can you post your authenticate user class?
– Szenis
Sep 11 '15 at 8:32
Done. posted code.
– Aditya Kappagantula
Sep 11 '15 at 8:35
Done. posted code.
– Aditya Kappagantula
Sep 11 '15 at 8:35
|
show 5 more comments
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
The problem was with the return url route!
I was returning to a wrong route from the application.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
The problem was with the return url route!
I was returning to a wrong route from the application.
add a comment |
up vote
0
down vote
accepted
The problem was with the return url route!
I was returning to a wrong route from the application.
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
The problem was with the return url route!
I was returning to a wrong route from the application.
The problem was with the return url route!
I was returning to a wrong route from the application.
answered Sep 12 '15 at 20:20
Aditya Kappagantula
3611416
3611416
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f32517421%2flaravel-socialite-request-returns-null%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I am following the laracast tutorial: laracasts.com/series/whats-new-in-laravel-5/episodes/9 But just not able to pass through this has('code').
– Aditya Kappagantula
Sep 11 '15 at 6:59
How does the form that triggers the function look like?
– Szenis
Sep 11 '15 at 7:07
Its not a form. I just trigger the route. <a class="btn btn-block btn-social btn-github" href={{ url('/github/auth') }}> <i class="fa fa-github"></i> Sign in with Github </a>
– Aditya Kappagantula
Sep 11 '15 at 7:12
can you post your authenticate user class?
– Szenis
Sep 11 '15 at 8:32
Done. posted code.
– Aditya Kappagantula
Sep 11 '15 at 8:35