我正在尝试使用API令牌来验证我们的用户,
这是我的config/auth.php代码
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'token',
'provider' => 'users',
],
],
Run Code Online (Sandbox Code Playgroud)
我Api.php就是这样
Route::group(['middleware' => ['subdomain_setup','auth::api'],'prefix'=>'v1'], function () {
Route::get('getCoupons','Api\CouponAPI@getCoupons');
});
Run Code Online (Sandbox Code Playgroud)
现在访问我的api URL时出现此错误
未找到列:1054“ where子句”中的未知列“ api_token”(SQL:select * from
userswhereapi_token=
小智 11
确保已运行Passport迁移并在中['guards']['api']['driver']设置为通行证config/auth.php,并更新了配置缓存
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'passport',
'provider' => 'users',
],
],
Run Code Online (Sandbox Code Playgroud)
小智 2
您必须更改表以添加“api_token”字段。
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email')->unique();
$table->string('password');
//Add api_token field
$table->string('api_token', 60)->unique();
$table->rememberToken();
$table->timestamps();
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7361 次 |
| 最近记录: |