private function createAuth(array $api, array $configAttributes, array $authorization) : AuthInterface
    {
        if (empty($api['authentication']['type'])) {
            $this->logger->debug("Using no authentication.");
            return new Authentication\NoAuth();
        }
        $this->logger->debug("Using '{$api['authentication']['type']}' authentication.");
        switch ($api['authentication']['type']) {
            case 'basic':
                if (!empty($config['password']) && empty($config['#password'])) {
                    $this->logger->warning("Using deprecated 'password', use '#password' instead.");
                }
                return new Authentication\Basic($configAttributes);
                break;
            /** @noinspection PhpMissingBreakStatementInspection */
            case 'url.query':
                $this->logger->warning("Method 'url.query' auth is deprecated, use 'query'.");
                // intentional, no break
            case 'query':
                if (empty($api['authentication']['query']) && !empty($api['query'])) {
                    $this->logger->warning("Using 'api.query' is deprecated, use 'api.authentication.query");
                    $api['authentication']['query'] = $api['query'];
                }
                return new Authentication\Query($configAttributes, $api['authentication']);
                break;
            case 'login':
                return new Authentication\Login($configAttributes, $api['authentication']);
                break;
            case 'oauth10':
                return new Authentication\OAuth10($authorization);
            case 'oauth20':
                return new Authentication\OAuth20($configAttributes, $authorization, $api['authentication']);
            case 'oauth20.login':
                return new Authentication\OAuth20Login($configAttributes, $authorization, $api['authentication']);
            default:
                throw new UserException("Unknown authorization type '{$api['authentication']['type']}'.");
                break;
        }
    }