addMinutes(DeviceAuthorization::EXPIRES_AFTER_MINUTES)->startOfSecond(); do { $userCode = $this->userCodes->generate(); } while (! Cache::add(DeviceAuthorization::userCodeKeyFor($userCode), $key, $expiresAt)); $authorization = new DeviceAuthorization($key, $fingerprint, $deviceName, $userCode, $expiresAt); Cache::put($key, $authorization->toArray(), $expiresAt); return ['device_code' => $deviceCode, 'authorization' => $authorization]; } }