Here's how I get the token.
After I get the Token in ArcGIS Enterprise, put it directly behind the service URL? token=xyz in this way, you can log in automatically?
POST /webadaptor/sharing/rest/generateToken HTTP/1.1
Host: machine.domain.com
Content-Type: application/x-www-form-urlencoded
Content-Length: []
username=admin&password=test1234&client=referer&ip=&referer=https://myserver/mywebapp&expiration=60&f=json