protected function initProvider($providerConfig)
    {
        $providerClass = $providerConfig['provider'];
        $options = $providerConfig['options'];

        if (!isset($options['redirectUri'])) {
            // Set OAuth 2.0 callback page from the configuration
            $options['redirectUri'] = $this->picoAuth->getPico()->getPageUrl($this->config["callbackPage"]);
        }

        if (!class_exists($providerClass)) {
            throw new \RuntimeException("Provider class $providerClass does not exist.");
        }

        if (!is_subclass_of($providerClass, AbstractProvider::class, true)) {
            throw new \RuntimeException("Class $providerClass is not a League\OAuth2 provider.");
        }

        $this->provider = new $providerClass($options);
        $this->providerConfig = $providerConfig;
    }