MongoCommandException: AuthenticationFailed - With MongoDB Atlas and AWS-EKS

I’ve successfully connected my application/pod in AWS-EKS to a MongoDB Atlas cluster using this authentication method: https://www.mongodb.com/docs/atlas/security/passwordless-authentication/#aws-eks. Logs indicate that the client successfully connects. But when doing a write operation it fails with:

com.mongodb.MongoSecurityException: Exception authenticating MongoCredential{mechanism=MONGODB-AWS, userName='ASIAXXXXXXXX', source='$external', password=<hidden>, mechanismProperties=<hidden>}

Caused by: com.mongodb.MongoCommandException: Command failed with error 18 (AuthenticationFailed): 'Authentication failed.' on server XXXXShard.XXXX.mongodb.net:27017. The full response is {"ok": 0.0, "errmsg": "Authentication failed.", "code": 18, "codeName": "AuthenticationFailed", "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1654860159, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "yBS9VFbLkDTcGYirWgQPzZAnUTY=", "subType": "00"}}, "keyId": 7106759389712744452}}, "operationTime": {"$timestamp": {"t": 1654860159, "i": 1}}}

Any tips what this can be?

Post can be deleted - solution found. Hadn’t URLEncoded AWS_SESSION_TOKEN param

It is best to keep the post and marked them as solved. This way others facing the same issue have an idea on how to solve it.