Lumen+JWT token + Flutter 请求:未授权错误

Lumen+JWT token + Flutter request: Unauthorized error

我有 flutter 应用程序使用 facebook 和 gmail 登录,我想在注册到 return 数据连接令牌后。

我对在数据库中成功注册的请求没有问题。 但我收到错误消息:请求完成并成功注册后出现未经授权的消息:

   $user = User::create(
       [
        'social_id'=>$request->id,   
        'username'=>$request->username,
        'email'=>$request->email,
        'pics'=>$request->pics,
        'role'=>'user'
       ]);
   if($user){
       $credentials = request(['email', 'password']);

       if (! $token = auth()->attempt($credentials)) {
           return response()->json(['error' => 'Unauthorized'], 401);
       }
       else{
       $data = [
        'social_id'=>$request->id, 
           'username'=>$request->username,
           'email'=>$request->email,
           'status' => 'success',
           'token' => $token
       ];}
   }
return $data;  

我解决了我的错误 我没有将密码保存到数据库,因为我不需要 更改后有效:

$user = User::create(
                   [
                    'social_id'=>$request->id,   
                    'username'=>$request->username,
                    'password'=>$password,
                    'email'=>$request->email,
                    'pics'=>$request->pics,
                    'role'=>'user'
                   ]);