[Vuejs]-Laravel Passport consuming own API fail

0πŸ‘

I had the same issue, decided to stick to client_secret way. I guess it’s not relevant for you now, but I’ve found 2 ways of receiving the laravel token without refresh:

1) sending dummy get request with axios or $http, whatever you use – token will get attached to response;

2) changing requestShouldReceiveFreshToken method in CreateFreshApiToken.php – replace return $request->isMethod('GET') && $request->user($this->guard); with return ($request->isMethod('GET') || $request->isMethod('POST')) && $request->user($this->guard);

πŸ‘€Be Kind

0πŸ‘

function consumeOwnApi($uri, $method = 'GET', $parameters = array())
{
    $req = \Illuminate\Http\Request::create($uri, $method, $parameters, $_COOKIE);
    $req->headers->set('X-CSRF-TOKEN', app('request')->session()->token());
    return app()->handle($req)->getData();
}
πŸ‘€huangfu

Leave a comment