This is my first time implementing OAuth to my projects. I found a walkthrough on github for laravel-5 oriceon/oauth-5-laravel. I followed all the steps correctly. However when I get to the controller function I get an error saying:
Call to undefined method Illuminate\Support\Facades\Request::get()
Here is my controller function:
public function loginWithFacebook(Request $request)
{
// get data from request
$code = $request->get('code');
// get fb service
$fb = \OAuth::consumer('Facebook');
// check if code is valid
// if code is provided get user data and sign in
if ( ! is_null($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((string)$url);
}
}
In the app you can see that i did add the correct provider and alias:
'OAuth' => Artdarek\OAuth\Facade\OAuth::class,
Artdarek\OAuth\OAuthServiceProvider::class,
In my view I call the route that leads to the correct controller function and I keep arriving to this error. What could it be that does this? Should the function be calling to the provider or something? Thanks for looking at this Stack!