Is it possible to pass configuration values as arguments to services? I'm writing a module that makes calls to a Web service to read and store data. 
Here's my services.yml file:

services:
  example.connection:
    class: Drupal\Core\Http\Client


I've already a settings form (inheriting from ConfigFormBase) that stores a base URL in configuration, and I'd like to pass that as an argument to the Client class's constructor. I've tried this:

class ExampleServiceProvider implements ServiceModifierInterface {

  /**
   * Modifies existing service definitions.
   *
   * @param ContainerBuilder $container
   *   The ContainerBuilder whose service definitions can be altered.
   */
  public function alter(ContainerBuilder $container) {
    $base_url = $container-&gt;get('config.factory')
        -&gt;get('example_entity.settings')-&gt;get('base_url');
    if ($base_url) {
      $arguments = array('base_url' =&gt; $base_url);
      $container-&gt;getDefinition('example.connection')
        -&gt;setArguments(array($arguments));
    }
  }
}


But that gives me HTTP 403 errors for every page on the site. Should it be possible to pass arbitrary arguments like this? Hardcoding a URL into the $base_url variable works fine.
In your services file add the following service:

# The bar configuration for the foo module
config.foo.bar.immutable:
  class: \Drupal\Core\Config\ImmutableConfig
  factory: config.factory:get
  arguments: ['bar']
config.foo.bar.mutable:
  class: \Drupal\Core\Config\Config
  factory: config.factory:getEditable
  arguments: ['bar']


In your service create method add either config.foo.bar.immutable or config.foo.bar.mutable service as an argument.