Consuming my own Laravel API

后端 未结 6 1072
傲寒
傲寒 2020-11-28 19:26

I\'m developing a Laravel 4 app that will make the same CRUD operations on my dataset available through a JSON REST API and a Web UI. It seems that to prevent breaking the D

6条回答
  •  广开言路
    2020-11-28 19:52

    If you are looking for using passport login api internally, then you need to add the parameters to original request:

        protected function manualLogin(Request $request)
        {
            $email = $request->input('email');
            $password = $request->input('password');
    
            $request->request->add([
            'username' => $email,
            'password' => $password,
            'grant_type' => 'password',
            'client_id' => $clientID,
            'client_secret' => $clientSecret,
            'scope' => '*']);
    
        $newRequest = Request::create('/oauth/token', 'post');
    
        return Route::dispatch($newRequest)->getContent();
    }
    

提交回复
热议问题