The real power of a cloud-hosted, fully managed service like MongoDB Atlas is that you can create whole new database deployment architectures automatically, using the services API. Getting to the MongoDB Atlas API is relatively simple and, once unlocked, it opens up a massive opportunity to integrate and automate the management of database deployments from creation to deletion. The API itself is an extensive REST API, there’s role-based access control and you can have user or app-specific credentials to access it.
There is one tiny thing that can trip people up though. The credentials have to be passed over using the digest authentication mechanism, not the more common basic authentication or using an issued token. Digest authentication, at its simplest, waits to get an HTTP 401 (not authorized) from the web endpoint. That response comes with data and the client then sends an encrypted form of the username and password as a digest and the server works with that.
And that’s why we are here today, to show you how to do that with the least fuss in Python, Node, and Ruby. In each example, we’ll try and access the base URL of the Atlas API which returns a JSON document about the underlying applications name, build and other facts.
#mongodb #api #node #python #ruby #javascript