Russian  English  All projects

Make device_token parameter generation for olx api



There is such a code, it generates an access token to the olx api

url = "https://m.olx.uz/api/open/oauth/token/"
headers = {
"User-Agent": "Mozilla/5.0 (iPhone CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Mobile/15E148 Safari/604.1",
"Accept": "*/*", "Accept-Language": "ru-RU,ruq=0.8,en-USq=0.5,enq=0.3", "Accept-Encoding": "gzip, deflate",
"Content-Type": "application/json", "X-Client": "MWEB", "Sec-Fetch-Dest": "empty", "Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-origin", "Te": "trailers"}
json = {"client_id": "100309", "client_secret": "QVnzW1SoFUt0JoNJmiBvMsKWkFvG9NUKZCdrjegVlZYCc8FR",
"device_id": "5a893215-bb29-42d8-aacf-32debffc17b2",
"device_token": "eyJpZCI6IjVhODkzMjE1LWJiMjktNDJkOC1hYWNmLTMyZGViZmZjMTdiMiJ9.149f712f6d811b3e4b25bf99436afe1e54944992",
"grant_type": "device", "scope": "i2 read write v2"}
r = requests.post(url, headers=headers, json=json).json()
print(r)

I want to generate device_id parameters and device_token myself, as I understood device_id
its any uuid4, but with device_token didnt quite understand how to generate it, found
on the site the script is obfuscated, where there is
device_token https://m.olx.uz/app/static/js/37951.eed9c67b6.chunk.js generation

here is the generation string in my opinion getDeviceToken:e=>{var t=new(0,r(7945). Buffer)(JSON.stringify({id:e})).toString("base64").replace(" ","/").replace("-","_"),n=new(o())("SHA-1","TEXT",{encoding:"UTF8",hmacKey:{value:"device",format:"TEXT"}})n.update(t)var a=n.getHash("HEX")return"".concat(t,"."). concat(a)}}}

i need to make an algorithm to generate device_token in python

24.10.2022 20:34



 Answers freelancers