关于passport client_credentials 模式 需要登录问题
请教一个问题。我想写一个http接口, 采用 laravel passport client_credentials模式,现在passport搭建好了。用postman测试也能取到token,但是我现在定义了一个接口。用postman测试 跳转到用户登录验证界面,不会进入我写接口内。我本意是不需要用户验证,因为我的接口提示给其他系统用的,不要用户验证。
在api.php中定义了Route::post('upload', 'UploadFileController@upload');
然后写了app/http/app/http/controllers中定义了一个控制器,代码如下:
namespace App\Http\Controllers;
class UploadFileController extends Controller {
//
public function upload() {
print_r($_POST);
print_r($_FILES);
file_put_contents('c:/ssss.log', 's');
}
}
kernel.php中我是这样定义的
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
// \Illuminate\Session\Middleware\AuthenticateSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
'api' => [
'throttle:60,1',
'bindings',
'client',
],
];
/**
* The application's route middleware.
*
* These middleware may be assigned to groups or used individually.
*
* @var array
*/
protected $routeMiddleware = [
'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'client' => \Laravel\Passport\Http\Middleware\CheckClientCredentials::class,
];
AuthServiceProvider.php 中 我是这样定义的
public function boot() {
$this->registerPolicies();
Passport::routes();
}
1 Comment
能不能把样式编辑下 不然这样贴出来谁愿意看呢