在独立项目上运行以基于密码的令牌身份验证时,Laravel Passport Auth身份卡住 [英] Laravel Passport Auth Stuck when run on standalone project for password based token authentication

查看:67
本文介绍了在独立项目上运行以基于密码的令牌身份验证时,Laravel Passport Auth身份卡住的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在同一项目的自助服务器和客户端上运行以进行基于密码的令牌身份验证时,Laravel Passport Auth身份卡住

Laravel Passport Auth Stuck when run on self server and client in same project for password based token authentication

LoginController

public function authenticaterrr(Request $request)

{
     $http = new Client();

    try{
                //dd("Hello");

        $response = $http->post(url('oauth/token'), [
        'form_params' => [
            'grant_type' => 'password',
            'client_id' => '2',
            'client_secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
            // 'username' => $request->get('username'),
            // 'password' => $request->get('password'),
              'username' => 'xxxxxx@xxxxx.com',
                'password' => 'xxxxx',
            'scope'     => '*',
         ],
         ]);

       //  $apiResponse = json_decode((string) $response->getBody(), true);

       // dd($apiResponse);
         $apiResponse = json_decode((string) $response->getBody(), true);

        dd($apiResponse);
        session(['api'=> $apiResponse]);
        session(['api-token'=> $apiResponse['access_token']]);
        return json_decode($response->getBody(), true);
    }catch (ClientException $exception){
        dd("Hello");
        return json_decode($exception->getResponse()->getBody(), true);
    }
}

IN Web.php

Route::get('/auth/api/validate', 'Auth\LoginController@authenticaterrr');

在PostMan中并没有卡住此处已输出

In PostMan It didn't Get and Stuck Here is Output

如果我将创建新项目并使用它,那么它将对我有用,那么在同一项目中运行将是什么解决方案

If i will create new Project and Use that than it will work for me so what would be solution to run in same project

推荐答案

如果您在内置PHP服务器/php artisan serve上运行Web应用程序,则第二个auth/token Passport请求杀死"第一个authenticaterrr HTTP请求.

If you're running your web app on the built-in PHP server / php artisan serve, then the second auth/token Passport request "kills" the first authenticaterrr HTTP request.

这是因为内置的PHP服务器是单线程.

This is because the built-in PHP server is single threaded.

查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆