Search code examples
phplaravelauthenticationlaravel-passport

Laravel passport: Lcobucci\JWT\Token\InvalidTokenStructure Value is not in the allowed date format


I created a laravel passport to authenticate apps via an api. The setup works local on my machine very well, but when I move the project to the server, I always get the following error: "Lcobucci\JWT\Token\InvalidTokenStructure Value is not in the allowed date format: 1616443683.7318161"

The user gets created and the registration throws an error 500 in the following line:

$success['token'] = $user->createToken('appToken')->accessToken;

Registration function

public function register(Request $request)
{
    $validator = Validator::make($request->all(), [
        'firstname' => 'required',
        'lastname' => 'required',
        'phone' => 'digits_between:4,30|numeric',
        'email' => 'required|email|unique:users',
        'password' => 'required',
    ]);

    if ($validator->fails()) {
        return response()->json([
            'success' => false,
            'message' => $validator->errors(),
        ], 401);
    }

    $input = $request->all();
    $input['password'] = bcrypt($input['password']);
    $user = User::create($input);
    $success['token'] = $user->createToken('appToken')->accessToken;

    return response()->json([
        'success' => true,
        'token' => $success,
        'user' => $user
    ]);
}

Solution

  • Downgrade Lcobucci\JWT from latest to v3.4