Getting error while trying to get authenticated user

Using dingo / api along with lucadegasperi / oauth2-server-laravel , the user authentication is ok and I get the access token, but anytime when I make another request, I get the following error:

call_user_func() expects parameter 1 to be a valid callback, no array or string given

I use the service provider parameter specified in dingo / api docs and it definitely sets a custom resolver (I would var_dump 'd the resolver in the setUserResolver method).

My OauthServiceProvider is below.

<?php namespace App\Providers;
use Dingo\Api\Auth\Auth;
use Dingo\Api\Auth\Provider\OAuth2;
use App\User\User;
use Illuminate\Support\ServiceProvider;

class OAuthServiceProvider extends ServiceProvider
{
    public function boot()
    {
        $this->app[Auth::class]->extend('oauth', function ($app) {
            $provider = new OAuth2($app['oauth2-server.authorizer']->getChecker());

            $provider->setUserResolver(function ($id) {
                return User::first();
                // Logic to return a user by their ID.
            });

            $provider->setClientResolver(function ($id) {
                // Logic to return a client by their ID.
            });

            return $provider;
        });
    }

    public function register()
    {
        //
    }
}
+4
source share
1 answer

, , , . config/api.php, auth

        'oauth2' => Dingo\Api\Auth\Provider\OAuth2::class,

        'oauth' => Dingo\Api\Auth\Provider\OAuth2::class,
+2

Source: https://habr.com/ru/post/1617649/


All Articles