Issue
I'm making this request and it only works with urllib3 and requests library i'm guessing it's because of ssl version or cert verification. any clue would be appreciated
import urllib3
params = {...}
http = urllib3.PoolManager(cert_reqs='CERT_NONE', assert_hostname=False)
r = http.request("POST", "https://android.clients.google.com/auth" , fields=params)
print(r.data)
this return Error=BadAuthentication
from urllib import request, parse
import urllib
params = {...}
data = parse.urlencode(params).encode()
req = request.Request("https://android.clients.google.com/auth", data=data)
try:
resp = request.urlopen(req)
print(resp.read())
except urllib.error.HTTPError as e:
print("error", e.read())
Solution
there was a problem with ciphers using this code worked for me
from urllib import request, parse
import urllib
import ssl
params = {...}
data = parse.urlencode(params).encode()
req = request.Request("https://android.clients.google.com/auth" , data=data) # this will make the method "POST"
DEFAULT_CIPHERS = ':'.join([
'TLS13-AES-256-GCM-SHA384',
'TLS13-CHACHA20-POLY1305-SHA256',
'TLS13-AES-128-GCM-SHA256',
'ECDH+AESGCM',
'ECDH+CHACHA20',
'DH+AESGCM',
'DH+CHACHA20',
'ECDH+AES256',
'DH+AES256',
'ECDH+AES128',
'DH+AES',
'RSA+AESGCM',
'RSA+AES',
'!aNULL',
'!eNULL',
])
ssl_context = ssl.SSLContext()
if getattr(ssl_context, 'supports_set_ciphers', True): # Platform-specific: Python 2.6
ssl_context.set_ciphers(DEFAULT_CIPHERS)
try:
resp = request.urlopen(req, context=ssl_context)
print(resp.read())
except urllib.error.HTTPError as e:
print("error", e.read())
Answered By - raoof Answer Checked By - Robin (WPSolving Admin)