I described the issue fully here: https://github.com/python-social-auth/social-core/issues/497
And I will copy it here. The full context is that I'm experiencing a failure with the Amazon backend provider for the Django third party library python-social-auth.
(https://python-social-auth.readthedocs.io/en/latest/backends/amazon.html)
The specific context is not really relevant however to the core issue, which is that Amazon does not honor requests without a User-Agent in the header.
Expected behaviour
Authentication with Amazon should work the same as any other backend like Facebook or Google. Particularly the call to https://www.amazon.com/ap/user/profile? should return a response: https://github.com/python-social-auth/social-core/blob/master/social_core/backends/amazon.py#L37
Actual behaviour
(Even beyond the scope of python-social-auth/social-core) when sending a request to https://www.amazon.com/ap/user/profile, requests fail from python code or cUrl commands, while they succeed from Postman or Web browsers.
Adding a 'User-Agent' to the headers in cUrl or in python fixes this issue such that I can request profile data and I get a successful response.
What are the steps to reproduce this issue?
Once you have a valid access_token from Amazon
you can try this with and without the 'user-Agent' header:
import requests
url_str= 'https://www.amazon.com/ap/user/profile?access_token=<your-access-token>'
headers = {
'User-Agent': 'Mozilla'
}
response = requests.request("GET", url=url_str, headers=headers)
print(response.text)
Any other comments?
This seems like an issue with Amazon, but who knows whether or not they will address this. I'm not sure where to send this issue to their side.