Advertisement
Guest User

Untitled

a guest
May 3rd, 2023
536
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.08 KB | None | 0 0
  1. import requests
  2.  
  3.  
  4. def get_url_encoded_object(data):
  5.     form_body = []
  6.     for key, value in data.items():
  7.         encoded_key = requests.utils.quote(key)
  8.         encoded_value = requests.utils.quote(value)
  9.         form_body.append(encoded_key + "=" + encoded_value)
  10.     form_body = "&".join(form_body)
  11.     return form_body
  12.  
  13.  
  14. def confirm_token_creation(code):
  15.     data = {
  16.         "grant_type": "urn:qiwi:oauth:grant-type:vcode",
  17.         "client_id": "qiwi_wallet_api",
  18.         "code": code,
  19.         "vcode": "тут код который придет"
  20.     }
  21.     headers = {
  22.         "Content-Type": "application/x-www-form-urlencoded",
  23.         "Cookie": "Тут куки с сайта киви"
  24.  
  25.     }
  26.     response = requests.post("https://qiwi.com/oauth/token", headers=headers, data=get_url_encoded_object(data))
  27.     if response.status_code == 200 and "access_token" in response.json():
  28.         print("TOKEN: " + response.json()["access_token"])
  29.     else:
  30.         print(response.content)
  31. confirm_token_creation('сюда нужно ввести вывод с кода выше')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement