Laravel 5.6 pass oauth/token hanging

前端 未结 2 1658
轻奢々
轻奢々 2020-12-22 09:24

I have set up a new laravel 5.6 install with Laravel Passport install. If I make a post request to http://127.0.0.1/oauth/token with Postman I get a valid token back:

<
相关标签:
2条回答
  • 2020-12-22 09:47

    This is because the built-in PHP server is single threaded. Hence your second (internal) request to the OAuth server is killing the first one.

    See my comment here.

    0 讨论(0)
  • 2020-12-22 09:48

    I have also tried to generate the token from curl or guzzle. try to use this code it works for me.

    function tokenRequest(Request $request){
    
      $request->request->add([
                    "grant_type" => "password",
                    "username" => $request->username,
                    "password" => $request->password,
                    "client_id"     => "2",
                    "client_secret" => "VE5S97DfjNciEWJOL1gEZhVLEx2VAGJQEX1dK6cq",
            ]);
    
            $tokenRequest = $request->create(
                    env('APP_URL').'/oauth/token',
                    'post'
            );
    
            $instance = Route::dispatch($tokenRequest);
    
            return json_decode($instance->getContent());
    
    }
    
    0 讨论(0)
提交回复
热议问题