To download the video youll need to find the list of mp4 and m4s files that compose the video (in the resolution you want) and then download them and reconstitute them into an mp4 file.
The high level of what you need to do is:
You can look at the source to see exactly how to do it. This github repo contains a python script that will download twitter videos. Otherwise, they send a legacy version of the website which doesnt contain the token. Note: The User-Agent needs to be set to something that Twitter believes to understand JavaScript. e., by download the websites content and parse its JavaScript.
You can get a fresh x-guest-token via curl -skL -H User-Agent: Firefox -compressed | grep -o gt=* | sed s.gt=. Python Downloading twitter video using python (without using twitter api)