I OAuth Dienstleister für Laravel 5 oriceon/oauth-5-laravelOriceon OAuth Laravel 5 - Call to undefined Methode OAuth :: Verbraucher()
Ich bin der Umsetzung bin diesen Fehler "Call to undefined Methode OAuth :: Verbraucher()". I wurde im Anschluss an die Info Schritte zur Installation:
I hinzugefügt "oriceon/oauth-5-Laravel": "dev-Master" in composer.json. Dann starte ich Composer Update, keine Fehler.
Ich habe hinzugefügt "Artdarek \ OAuth \ OAuthServiceProvider :: class" in 'Anbieter' Array app.php
ich hinzugefügt haben „ 'OAuth' => Artdarek \ OAuth \ Fassade \ OAuth :: Klasse“in Reihe 'Aliase' in app.php
Hier ist meine config/oauth-5-laravel.php:
return [
/*
|--------------------------------------------------------------------------
| oAuth Config
|--------------------------------------------------------------------------
*/
/**
* Storage
*/
'storage' => '\\OAuth\\Common\\Storage\\Session',
/**
* Consumers
*/
'consumers' => [
'Facebook' => [
'client_id' => '',
'client_secret' => '',
'scope' => [],
],
'Google' => [
'client_id' => env('GOOGLE_CLIENT_ID'),
'client_secret' => env('GOOGLE_SECRET_ID'),
'scope' => ['userinfo_email', 'userinfo_profile'],
],
]
];
Hier ist mein GoogleController.php:
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use OAuth;
class GoogleController extends Controller
{
public function loginWithGoogle(Request $request)
{
// get data from request
$code = $request->get('code');
// get google service
$googleService = \OAuth::consumer('Google');
// 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 google, get the token
$token = $googleService->requestAccessToken($code);
// Send a request with it
$result = json_decode($googleService->request('https://www.googleapis.com/oauth2/v1/userinfo'), true);
$message = 'Your unique Google 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 googleService authorization
$url = $googleService->getAuthorizationUri();
// return to google login url
return redirect((string)$url);
}
}
}