title: authentication error trying to initiate replica set in pymongo
body: <p>Trying to initiate a mongodb replica set from a python script, and running into an error with authentication.</p>
  
  <pre class="lang-py prettyprint-override"><code>from pymongo import MongoClient
  
  ip = 'zzz.zz.zzz.zz'
  port = 27017
  replica_set = 'yomama'
  
  config = {
    '_id': replica_set,
    'members': [
      {'host': 'xxx.xx.xxx.xx',
       '_id': 0,
       'arbiterOnly': False},
      {'host': 'yyy.yy.yyy.yy',
       '_id': 1,
       'arbiterOnly': False},
      {'host': 'zzz.zz.zzz.zz',
       '_id': 2,
       'arbiterOnly': False},
    ],
  }
  
  connection = MongoClient(ip, port)
  connection.admin.command('replSetInitiate', config)
  </code></pre>
  
  <p>Running this script results in:</p>
  
  <pre><code>pymongo.errors.OperationFailure: command SON([('replSetInitiate', {'_id': 'yomama', 'members': [{'host': 'xxx.xx.xxx.xx', '_id': 0, 'arbiterOnly': False}, {'host': 'yyy.yy.yyy.yy', '_id': 1, 'arbiterOnly': False}, {'host': 'zzz.zz.zzz.zz', '_id': 2, 'arbiterOnly': False}]})])
  failed: unauthorized
  </code></pre>
  
  <p>There is no authentication set up on the database, and running the same thing from a mongo shell works fine:</p>
  
  <pre><code>db.runCommand({replSetInitiate:{'_id': 'yomama', 'members': [{'host': 'xxx.xx.xxx.xx', '_id': 0, 'arbiterOnly': false}, {'host': 'yyy.yy.yyy.yy', '_id': 1, 'arbiterOnly': false}, {'host': 'zzz.zz.zzz.zz', '_id': 2, 'arbiterOnly': false}]}})
  {
      "info" : "Config now saved locally.  Should come online in about a minute.",
      "ok" : 1
  }
  </code></pre>
  
  <p>Any thoughts on why this error when doing the same thing with pymongo?</p>