I am trying to figure out one weird issue. I have working python code which I want to translate to NodeJS. Python code very simple and works:
import requests
LOGIN_URL = 'https://android.clients.google.com/auth'
params = {'Email': '***', 'EncryptedPasswd': b'***', 'service': 'androidmarket', 'accountType': 'HOSTED_OR_GOOGLE', 'has_permission': 1, 'source': 'android', 'device_country': 'us', 'lang': 'us'}
response = requests.post(LOGIN_URL, data=params, verify=True)
print(response.text)
Here is NodeJS version code:
const request = require('request');
const LOGIN_URL = 'https://android.clients.google.com/auth'
const params = {'Email': '***', 'EncryptedPasswd': '***', 'service': 'androidmarket', 'accountType': 'HOSTED_OR_GOOGLE', 'has_permission': 1, 'source': 'android', 'device_country': 'us', 'lang': 'us'}
request({url: LOGIN_URL, method: 'POST', form: params}, function(error, response) {
console.log(response.statusCode);
});
This does not work, I am getting back 403 - Bad request. I have tried to change protocol to http and then check packets contents in Wireshark. They are pretty much same with minor differences. I tried eliminating all the differences by overriding headers in NodeJS version, it did not help. So my guess is something wrong with https?
What am I missing? What could be the difference between Python and NodeJS?