[GODRIVER-1236] Get mLab Client Authentication Fails Created: 15/Aug/19  Updated: 27/Oct/23  Resolved: 16/Aug/19

Status: Closed
Project: Go Driver
Component/s: None
Affects Version/s: 1.1.0
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Shishir Jakati Assignee: Kristofer Brandow (Inactive)
Resolution: Gone away Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
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). 



 Comments   
Comment by Shishir Jakati [ 15/Aug/19 ]

@Kristofer Brandow, 

 

Sorry for opening an issue. Was user error. Name of the database was incorrect.

Comment by Kristofer Brandow (Inactive) [ 15/Aug/19 ]

Hi shishir.jakati98@gmail.com,

I used the exact example that you provided and received no errors. Are you using the 1.1.0 version of the driver and what version of Go are you using?

--Kris

Generated at Thu Feb 08 08:35:59 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.