Socialite показывает ошибку Драйвер [обратный вызов] не поддерживается

Я разрабатываю социальную учетную запись, используя пакет Socialite. Мне удалось войти через Twitter и Google+, но с помощью Facebook я получаю следующее сообщение об ошибке, не знаю, чего не хватает

InvalidArgumentException in Manager.php line 90:
    Driver [callback] not supported.

Вот мой код.. ошибка, возникшая, когда я нажимаю на кнопку входа в Facebook, которая приводит меня к redirectToProvider метод, поэтому ошибка происходит, когда я иду в

Socialite::driver($provider)->stateless()->redirect()

Когда приложение Facebook возвращает URI перенаправления, когда я вижу эту ошибку

контроллер

namespace App\Http\Controllers\Auth;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Socialite;

class AuthenticateController extends Controller {
    public function redirectToProvider($provider) {
        if (isset($provider)) {
            return Socialite::driver($provider)->stateless()->redirect();
        } else {
            return Socialite::driver('facebook')->stateless()->redirect();
        }
    }

    public function handleProviderCallback() {
        // this user we get back is not our user model, but a special user object that has all the information we need
        $providerUser = Socialite::driver('facebook')->stateless()->user();

        // we have successfully authenticated via facebook at this point and can use the provider user to log us in.
        // for example we might do something like... Check if a user exists with the email and if so, log them in.
        $user = User::query()->firstOrNew(['email' => $providerUser->getId()]);

        // maybe we can set all the values on our user model if it is new... right now we only have name
        // but you could set other things like avatar or gender
        if (!$user->exists) {
            $user->name = $providerUser->getName();
            $user = $user->save(); // just because I want it to return the user id in my example
        }


        /**
         * At this point we done.  You can use whatever you are using for authentication here...
         * for example you might do something like this if you were using JWT
         * */
        $token = JWTAuth::fromUser($user);

        return new JsonResponse([
            'token' => $token
        ]);
    }

    /**
     * Obtain the user information from Facebook.
     *
     * @return JsonResponse
     */
    public function handleTwitterCallback() {
        // this user we get back is not our user model, but a special user object that has all the information we need
        $providerUser = Socialite::driver('twitter')->stateless()->user();

        // we have successfully authenticated via facebook at this point and can use the provider user to log us in.
        // for example we might do something like... Check if a user exists with the email and if so, log them in.
        $user = User::query()->firstOrNew(['email' => $providerUser->getId()]);

        // maybe we can set all the values on our user model if it is new... right now we only have name
        // but you could set other things like avatar or gender
        if (!$user->exists) {
            $user->name = $providerUser->getName();
            $user = $user->save(); // just because I want it to return the user id in my example
        }


        /**
         * At this point we done.  You can use whatever you are using for authentication here...
         * for example you might do something like this if you were using JWT
         * */
        $token = JWTAuth::fromUser($user);

        return new JsonResponse([
            'token' => $token
        ]);
    }
}

.env

FACEBOOK_ID=*********
FACEBOOK_SECRET=*********
FACEBOOK_URL=https://test.pop-deal.com/login/callback

конфиг /services.php

    <?php

return [
    'facebook' => [
        'client_id'     => env('FACEBOOK_ID'),
        'client_secret' => env('FACEBOOK_SECRET'),
        'redirect'      => env('FACEBOOK_URL'),
    ],
    'twitter' => [
        'client_id' => env('TWITTER_ID'),
        'client_secret' => env('TWITTER_SECRET'),
        'redirect' => env('TWITTER_URL'),  
    ],
        'google' => [
        'client_id' => env('GOOGLE_ID'),
        'client_secret' => env('GOOGLE_SECRET'),
        'redirect' => env('GOOGLE_URL'),  
    ],

];

конфиг /app.php

    <?php

return [
    'providers' => [
        .
        .
        .
        .
        .   
        Laravel\Socialite\SocialiteServiceProvider::class,
    ],

    'aliases' => [
        .
        .
        .
        .
        .   
        'Socialite' => Laravel\Socialite\Facades\Socialite::class,
    ],
];

0 ответов

Другие вопросы по тегам