[GODRIVER-504] how to NewClient with SCRAM-SHA-1, usename, password and database Created: 20/Jul/18 Updated: 11/Sep/19 Resolved: 27/Jul/18 |
|
| Status: | Closed |
| Project: | Go Driver |
| Component/s: | Authentication, Connections |
| Affects Version/s: | 0.0.9 |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | orange.jackylee | Assignee: | Kristofer Brandow (Inactive) |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
linux |
||
| Description |
|
package main import ( func main() { f1() }func f1() { ) client, err := mongo.NewClientWithOptions("mongodb://localhost:27017", single, serverSTimeout, appname, sockTimout, conTimeout, auth) err = client.Connect(context.Background()) if err != nil { log.WithError(err).Fatal("error connecting") } fmt.Println(client.ListDatabases(context.Background(), nil)) collection := client.Database("xxx").Collection("test") cur, err := collection.Find(context.Background(), nil) defer cur.Close(context.Background()) // do something with elem.... } than go run main.go, it outputs command-line-arguments {[] 0} auth error: sasl conversation error: unable to authenticate using mechanism "SCRAM-SHA-1": Authentication failed. how to make it works |
| Comments |
| Comment by orange.jackylee [ 21/Jul/18 ] |
|
thank you kris brandow, after connection string add database, it works. |
| Comment by Kristofer Brandow (Inactive) [ 20/Jul/18 ] |
|
Hello jackylee, Does your connection string have a database in it? For instance, if your connection string is "mongodb://localhost:27017/foo" then "foo" would be the database. Thanks, Kris |