static function getInstance($clientId, $clientSecret, $redirectUri, $certificateFile = '')
    {
        $driver = static::getLibrary();

        try {
            $instance = new $driver($clientId, $clientSecret, $redirectUri);
        } catch (\Exception $e) {
            throw new Exception('Unable to create an instance of ' . $driver);
        }

        if (!self::isInstanceOf($instance, OAuth2Interface::class)) {
            throw new Exception(Exception::MSG_INVALID_ARG, ['driver', OAuth2Interface::class]);
        }

        if ($certificateFile != '') {
            $instance->setCertificate($certificateFile);
        }

        return $instance;
    }