protected function getAuthorizationServer()
    {
        if (! $this->authorizationServer) {
            $config = $this->config[$this->grant];

            $options = [
                'url' => $this->authorizationServerUri,
                'clientId' => $config['client_id'],
                'clientSecret' => $config['client_secret'],
            ];

            if (! empty($config['redirect_uri'])) {
                $options['redirectUri'] = $this->getFrameworkBridge()->prepareUrl($config['redirect_uri']);
            }

            // Allow setting a custom handler (for mocking requests in tests).
            if (! empty($this->config['handler'])) {
                $options['handler'] = $this->config['handler'];
            }

            $this->authorizationServer = new NorthstarOAuthProvider($options);
        }

        return $this->authorizationServer;
    }