Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call to a member function getAuthorizationUri() on null: Facebook Login Issue with Facebook Graph API Version 2.8 #181

Open
sw-tt-aniruddhbhavsar opened this issue Apr 5, 2017 · 0 comments

Comments

@sw-tt-aniruddhbhavsar
Copy link

sw-tt-aniruddhbhavsar commented Apr 5, 2017

Hi,

I have configured this package with laravel 4.2.17. When i am trying to create login with facebook i am getting an error "Call to a member function getAuthorizationUri() on null". I have created new App in Facebook with version 2.8 and set redirect url in config file same as configured in Facebook App.

facebook login issue

Below is my code in Controller.php:

public function loginWithFacebook() {

// get data from input
$code = Input::get( 'code' );

// get fb service
$return_url = URL::to('/') ."/login/fb/";

$fb = OAuth::consumer( 'Facebook',$return_url );

// check if code is valid

// if code is provided get user data and sign in
if ( !empty( $code ) ) {
	
	// This was a callback request from facebook, get the token
	$token = $fb->requestAccessToken( $code );
	
	// Send a request with it
	$result = json_decode( $fb->request( '/me' ), true );
	
	$message = 'Your unique facebook user id is: ' . $result['id'] . ' and your name is ' . $result['name'];
	echo $message. "<br/>";
	
	//Var_dump
	//display whole array().
	dd($result);

}
// if not ask for permission first
else {
	// get fb authorization
	$url = $fb->getAuthorizationUri();
	
	// return to facebook login url
	 return Redirect::to( (string)$url );
}

}

Below is my code in app/config/app.php:

'providers' => array(
	'Artdarek\OAuth\OAuthServiceProvider'
),

'aliases' => array(
	'OAuth' => 'Artdarek\OAuth\Facade\OAuth',
),

I have updated Facebook App client_id and client_secret in my app/config/oauth-4-laravel.php:

Also getting a same issue for Login with Linkedin, Google. Thanks in advance for help.

@sw-tt-aniruddhbhavsar sw-tt-aniruddhbhavsar changed the title Facebook Login Issue with Facebook Graph API Version 2.8 Call to a member function getAuthorizationUri() on null: Facebook Login Issue with Facebook Graph API Version 2.8 Apr 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant