Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-1236

Get mLab Client Authentication Fails

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Gone away
    • Affects Version/s: 1.1.0
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      Mac OSX

      Description

      Connecting to a client works fine:

      var MongoURI = "mongodb://usermanagement:Jn4LEWxPBuqynRTjz7qd@ds159273.mlab.com:59273/goautoauto-usermanagement"
      var client *mongo.Client
      // creates an empty option
      opt := options.Client()
      opt.ApplyURI(MongoURI)
      client, err := mongo.NewClient(opt)
      if err != nil {
         ...
      }
      

      In this case I am able to get a client with no error, and connect with no error using the `client.Connect(ctx)` method.

       

      The problem comes when I attempt to do a simple count operation:

      n, err = c.client.Database(database).Collection(userCollection).CountDocuments(context.Background(), bson.M{})
      

      In this case, I get the error:

      error counting documents in user collection: (Unauthorized) not authorized on
      

      I am sure that the user/pass used in the URI are correct, as I used the same text when connecting with the Mongo shell (on the shell I do not get any unauthorized errors). 

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: