public static function createFromConfig($config, $rpcHelper = null) {
    $clientId = $config['clientId'];
    $projectId = $config['projectId'];
    if (!isset($clientId) && !isset($projectId)) {
      throw new Gitkit_ClientException("Missing projectId or clientId in server configuration.");
    }
    if (!isset($config['widgetUrl'])) {
      throw new Gitkit_ClientException("\"widgetUrl\" should be configured");
    }
    if (isset($config["cookieName"])) {
      $cookieName = $config['cookieName'];
    } else {
      $cookieName = self::$DEFAULT_COOKIE_NAME;
    }
    if (!$rpcHelper) {
      if (!isset($config['serviceAccountEmail'])) {
        throw new Gitkit_ClientException(
            "\"serviceAccountEmail\" should be configured");
      }
      if (!isset($config['serviceAccountPrivateKeyFile'])) {
        throw new Gitkit_ClientException(
            "\"serviceAccountPrivateKeyFile\" should be configured");
      }
      $p12Key = file_get_contents($config["serviceAccountPrivateKeyFile"]);
      if ($p12Key === false) {
        throw new Gitkit_ClientException(
            "Can not read file " . $config["serviceAccountPrivateKeyFile"]);
      }
      if (isset($config['serverApiKey'])) {
        $serverApiKey = $config['serverApiKey'];
      } else {
        $serverApiKey = null;
      }
      $rpcHelper = new Gitkit_RpcHelper(
          $config["serviceAccountEmail"],
          $p12Key,
          self::$GITKIT_API_BASE,
          new Google_Auth_OAuth2(new Google_Client()),
          $serverApiKey);
    }
    return new Gitkit_Client($clientId, $config['widgetUrl'],
        $cookieName, $rpcHelper, $projectId);
  }