connection() : auth error: sasl conversation error: unable to authenticate using mechanism "SCRAM-SHA-1": (AuthenticationFailed) Authentication failed.

8,667 views
Skip to first unread message

邢永涛

unread,
Nov 26, 2019, 10:56:41 PM11/26/19
to mongodb-go-driver
Hi everyone:

is mongo go driver support "SCRAM-SHA-1" default authentication mechanism?

when i ping the database, i got this error:

connection() : auth error: sasl conversation error: unable to authenticate using mechanism "SCRAM-SHA-1": (AuthenticationFailed) Authentication failed.

code is like this:
ctx, _ := context.WithTimeout(context.Background(), 10*time.Second)
client
, err := mongo.Connect(ctx, option)
err = client.Ping(ctx, readpref.Primary()) // got error here

anyone help? thank you very much.

邢永涛

unread,
Nov 27, 2019, 1:30:46 AM11/27/19
to mongodb-go-driver
i move the username and password to URI, problem solved.

before
option := options.Client().ApplyURI("mongodb://host:port/db")
option
.setAuth(auth)

after
option := options.Client().ApplyURI("mongodb://username:password@host:port/db")

hope it's useful for others.
Reply all
Reply to author
Forward
0 new messages