public function get_login_url() {

        $callbackurl = self::callback_url();
        $params = array_merge(
            [
                'client_id' => $this->clientid,
                'response_type' => 'code',
                'redirect_uri' => $callbackurl->out(false),
                'state' => $this->returnurl->out_as_local_url(false),
                'scope' => $this->scope,
            ],
            $this->get_additional_login_parameters()
        );

        return new moodle_url($this->auth_url(), $params);
    }