### Install axios-digest-auth Source: https://github.com/mhoc/axios-digest-auth/blob/master/README.md Installs the axios-digest-auth library using npm. This is the primary method to add the package to your project's dependencies. ```bash $ npm i @mhoc/axios-digest-auth ``` -------------------------------- ### Install @mhoc/axios-digest-auth Source: https://github.com/mhoc/axios-digest-auth/blob/master/docs/docs/index.md Installs the @mhoc/axios-digest-auth library using npm. This is the first step to integrate digest authentication into your NodeJS project. ```bash $ npm i @mhoc/axios-digest-auth ``` -------------------------------- ### Initialize and Use AxiosDigestAuth Source: https://github.com/mhoc/axios-digest-auth/blob/master/docs/docs/index.md Demonstrates initializing the AxiosDigestAuth class with username and password, then making a GET request to a cloud API. It shows how to configure headers and the request URL. ```javascript import AxiosDigestAuth from '@mhoc/axios-digest-auth'; const digestAuth = new AxiosDigestAuth({ username: process.env.MY_DIGEST_USERNAME, password: process.env.MY_DIGEST_PASSWORD, }); const MakeARequest = async () => { const response = await digestAuth.request({ headers: { Accept: "application/json" }, method: "GET", url: "https://cloud.mongodb.com/api/atlas/v1.0/groups", }); } ``` -------------------------------- ### Instantiate AxiosDigestAuth Class Source: https://github.com/mhoc/axios-digest-auth/blob/master/docs/docs/api.md Demonstrates how to create an instance of the AxiosDigestAuth class. It requires an options object containing the Axios instance, username, and password for authentication. ```TypeScript import * as axios from "axios"; // Assuming username and password are defined elsewhere const username = "your_username"; const password = "your_password"; const options: AxiosDigestAuthOpts = { axios: axios.default, // Or a pre-configured axios instance password, username, }; const axiosDigestAuthInst = new AxiosDigestAuth(options); ``` -------------------------------- ### Import AxiosDigestAuth Class Source: https://github.com/mhoc/axios-digest-auth/blob/master/docs/docs/api.md Imports the main AxiosDigestAuth class from the library. This is the primary entry point for using the authentication functionality. ```TypeScript import AxiosDigestAuth from "@mhoc/axios-digest-auth"; ``` -------------------------------- ### Execute Request with AxiosDigestAuth Source: https://github.com/mhoc/axios-digest-auth/blob/master/docs/docs/api.md Shows how to execute an HTTP request using an AxiosDigestAuth instance. The method signature is identical to Axios's own `request` method, allowing for standard Axios request configurations. ```TypeScript import * as axios from "axios"; // Assuming axiosDigestAuthInst is already instantiated const ExecuteMyRequest = async () => { const requestOptions: axios.AxiosRequestConfig = { headers: { Accept: "application/json" }, method: "GET", url: "https://cloud.mongodb.com/api/atlas/v1.0/groups", }; try { const response: axios.AxiosResponse = await axiosDigestAuthInst.request(requestOptions); console.log("Request successful:", response.data); } catch (error) { console.error("Request failed:", error); } }; // To execute the request: // ExecuteMyRequest(); ``` -------------------------------- ### AxiosDigestAuthOpts Interface Definition Source: https://github.com/mhoc/axios-digest-auth/blob/master/docs/docs/api.md Defines the structure for the options object required when instantiating the AxiosDigestAuth class. It specifies the types and purposes of each configuration parameter. ```APIDOC interface AxiosDigestAuthOpts { // Optionally provide an axios object with which requests are made. // If this is not provided, axios-digest-auth will create one for you by simply using the axios library default export, with no configuration. axios?: axios.Axios; // Type: axios.Axios | undefined // The HTTP digest authentication password to use. password: string; // The HTTP digest authentication username to use. username: string; } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.