public function authenticate($key = null)
 {
     $key = $key ?: $this->parseKey();
     if (is_null($keyRecord = ApiKey::getByKey($key))) {
         throw new \RuntimeException('Invalid API key.');
     }
     return $keyRecord;
 }