Skip to content

Commit 1a7f496

Browse files
authored
Add a common issues section for 'authentication failed' errors. (#1116)
1 parent c4073ad commit 1a7f496

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

docs/common-issues.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Frequently Encountered Issues
22

3+
These are fixes or information for common issues encountered by Go Driver users. If none of these are helpful, [create a GODRIVER Jira ticket](https://jira.mongodb.org/secure/CreateIssue!default.jspa) and we'll try to troubleshoot your issue!
4+
35
## `WriteXXX` can only write while positioned on a Element or Value but is positioned on a TopLevel
46

57
The [`bson.Marshal`](https://pkg.go.dev/go.mongodb.org/mongo-driver/bson#Marshal) function requires a parameter that can be decoded into a BSON Document, i.e. a [`primitive.D`](https://github.com/mongodb/mongo-go-driver/blob/master/bson/bson.go#L31). Therefore the error message
@@ -49,4 +51,15 @@ if err := json.Unmarshal(jsonBytes, &m); err != nil {
4951
fmt.Printf("json: %v\n", m)
5052
```
5153

54+
## Authentication Failed
55+
56+
When connecting to a MongoDB deployment with password authentication enabled, if your authentication information or configuration are incorrect, you may encounter an error message like:
57+
58+
> connection() error occurred during connection handshake: auth error: sasl conversation error: unable to authenticate using mechanism "SCRAM-SHA-256": (AuthenticationFailed) Authentication failed.
59+
60+
That error can be caused by a number of issues. The error message intentionally omits the exact authentication failure reason (see the [OWASP Authentication and Error Messages guidelines](https://cheatsheetseries.owasp.org/cheatsheets/Authentication_Cheat_Sheet.html#authentication-and-error-messages) for an explanation). Possible causes of the error include:
61+
- Incorrect password.
62+
- Incorrect username.
63+
- Incorrect authentication database (i.e. [authSource](https://www.mongodb.com/docs/manual/reference/connection-string/#mongodb-urioption-urioption.authSource)).
5264

65+
If you encounter an `AuthenticationFailed` error like the one above, check that the username and password in your [connection string](https://www.mongodb.com/docs/manual/reference/connection-string/) or [SetAuth](https://pkg.go.dev/go.mongodb.org/mongo-driver/mongo/options#ClientOptions.SetAuth) call are correct. In most cases, [authSource](https://www.mongodb.com/docs/manual/reference/connection-string/#mongodb-urioption-urioption.authSource) does not need to be specified unless you are using a non-default authentication database (the default is "admin").

0 commit comments

Comments
 (0)