First, visit the required login URL to access Instagram from a client-side application. Now extract all the cookies from the site and add values as the cookies
header, then request to bypass the 401 status code. Sometimes Facebook returns 404 for the private page post too. Handle the cases accordingly.
To extract these cookies, follow the instructions on the following page: https://github.com/ytdl-org/youtube-dl#how-do-i-pass-cookies-to-youtube-dl.