Lumen+JWT token + Flutter request: Unauthorized error

  jwt, laravel, lumen, unauthorized

I have flutter app use login with facebook and gmail ,I want after register to return data conatin token.

I have no problem with request which register in database successfully.
but I get error : Unauthorized message after the request done and registered successfully :

   $user = User::create(
       $credentials = request(['email', 'password']);

       if (! $token = auth()->attempt($credentials)) {
           return response()->json(['error' => 'Unauthorized'], 401);
       $data = [
           'status' => 'success',
           'token' => $token
return $data;  

Source: Laravel

Leave a Reply