Request not redirecting when I use a user agent

I am making a request to a twitter shortened url that redirects to amazon. When I don't use a user agent it redirects perfectly, when I use a user agent it no longer redirects.

## Expected Result

Make a request to a twitter shortened url for an amazon link with a user agent header and it successfully redirect to amazon.

## Actual Result

When I add a user agent to my request, it is no longer redirecting to amazon. (When I remove the user agent again, the request redirects perfectly fine to amazon.

## Reproduction Steps

```python
import requests

header = {'User-Agent': 'Mozilla/5.0 (iPad; CPU OS 8_1_2 like Mac OS X; en-US) AppleWebKit/534.20.2 (KHTML, like Gecko) Version/4.0.5 Mobile/8B116 Safari/6534.20.2'}

session = requests.Session()
session.headers.update(header)
request = session.head("https://t.co/ErjlKsTuZy?amp=1", allow_redirects=True)
amazon_link = request.url
```

## System Information

    $ python3 -m requests.help

```
{
  "chardet": {
    "version": "3.0.4"
  },
  "cryptography": {
    "version": "2.6.1"
  },
  "idna": {
    "version": "2.8"
  },
  "implementation": {
    "name": "CPython",
    "version": "3.7.3"
  },
  "platform": {
    "release": "5.4.51-v7l+",
    "system": "Linux"
  },
  "pyOpenSSL": {
    "openssl_version": "1010104f",
    "version": "19.0.0"
  },
  "requests": {
    "version": "2.25.1"
  },
  "system_ssl": {
    "version": "1010104f"
  },
  "urllib3": {
    "version": "1.24.1"
  },
  "using_pyopenssl": true

```

This command is only available on Requests v2.16.4 and greater. Otherwise,
please provide some basic information about your system (Python version,
operating system, &c).


Hi @trevtravtrev, there's a handful of closed issues already discussing this behavior and it's pretty quick to self validate. If you shut off redirects and check the `status_code` and `headers` returned from the first request, you'll see Twitter isn't returning a redirect with the custom user-agent. They're doing something server side to circumvent scraping and this is unrelated to Requests.

@nateprewitt Don't you find the behavior strange that it redirects without a user agent but not with one?

I just tested it with a different link shortener (amzn.to) and got the exact same behavior. Without a user agent it redirects fine, with a user agent it does not redirect.

Is this a coincidence?

No, because it's not the behavior changing because the user agent is included, it's changing because of the *specific* user agent you're supplying. Doing the same thing with a custom user-agent works fine. This is entirely server side, we can't change how they respond.

```
import requests

header = {'User-Agent': 'MyBot/1.0'}

session = requests.Session()
session.headers.update(header)
request = session.head("https://t.co/ErjlKsTuZy?amp=1", allow_redirects=True)
amazon_link = request.url
```

Has anyone found a workaround for user agents that work? I've tried over 30 user agents that spoof all of the major web browsers and devices but none worked. I have not tried something like you provided "MyBot/1.0" and am not in front of a computer to test. Did you mean that specific user agent just worked for you and redirected when you tested?

If you look at the response, it's performing a javascript redirect for your user agents rather than a 302 because you're falsely claiming to be a full fledged browser. This isn't the appropriate venue for these kinds of questions though, please open a question on StackOverflow for further help. Thanks!