请求缺少必需参数、包含无效参数值、多次包含参数或格式错误

osh*_*abz 5 php laravel postman laravel-5.3 laravel-passport

我正在使用 laravel、passport 和 postman 开发一个 auth api。我看过相关帖子,但没有一个能解决我的问题。如果我尝试发送请求,它会显示此错误。我已尽我所能,但它只显示此错误

{
"error": "invalid_request",
"message": "The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed.",
"hint": "Check the `username` parameter"
}
Run Code Online (Sandbox Code Playgroud)

我对应用程序的价值是

{
"grant_type" : "password",
"client_id" : "2",
"client_secret" : "fsDFrzGtmpMjoxWtplnvcmgKT3USzKFfKQu6alGF",
"email":"john@gmail.com",
"pssword" : "12345",
"scope" : "*"
}
Run Code Online (Sandbox Code Playgroud)

api.php

<?php
 use Illuminate\Http\Request;
 Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request->user();
});
Route::post('signup', 'SignUp@signUp');
Run Code Online (Sandbox Code Playgroud)

验证文件

'guards' => [
    'web' => [
        'driver' => 'session',
        'provider' => 'users',
    ],

    'api' => [
        'driver' => 'passport',
        'provider' => 'users',
    ],


'providers' => [
    'users' => [
        'driver' => 'eloquent',
        'model' => App\User::class,
    ],
Run Code Online (Sandbox Code Playgroud)

用户.php

class User extends Authenticatable
  {
use Notifiable;

/**
 * The attributes that are mass assignable.
 *
 * @var array
 */
protected $fillable = [
    'name', 'email', 'password','vCode',
];

/**
 * The attributes that should be hidden for arrays.
 *
 * @var array
 */
protected $hidden = [
    'password', 'remember_token',
];
Run Code Online (Sandbox Code Playgroud)

AuthServiceProvider.php

namespace App\Providers;

use Laravel\Passport\Passport;
use Illuminate\Support\Facades\Gate;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;

  class AuthServiceProvider extends ServiceProvider
{
    /**
     * The policy mappings for the application.
     *
     * @var array
     */
    protected $policies = [
        'App\Model' => 'App\Policies\ModelPolicy',
    ];

    /**
     * Register any authentication / authorization services.
     *
     * @return void
     */
    public function boot()
    {
        $this->registerPolicies();

        //
        Passport::routes();
    }
}
Run Code Online (Sandbox Code Playgroud)

请任何解决方案将非常感激

小智 5

您需要“用户名”字段并在邮递员参数中传递值毕竟您的代码绝对正确。没有任何错误。