Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- def get_url_encoded_object(data):
- form_body = []
- for key, value in data.items():
- encoded_key = requests.utils.quote(key)
- encoded_value = requests.utils.quote(value)
- form_body.append(encoded_key + "=" + encoded_value)
- form_body = "&".join(form_body)
- return form_body
- def confirm_token_creation(code):
- data = {
- "grant_type": "urn:qiwi:oauth:grant-type:vcode",
- "client_id": "qiwi_wallet_api",
- "code": code,
- "vcode": "тут код который придет"
- }
- headers = {
- "Content-Type": "application/x-www-form-urlencoded",
- "Cookie": "Тут куки с сайта киви"
- }
- response = requests.post("https://qiwi.com/oauth/token", headers=headers, data=get_url_encoded_object(data))
- if response.status_code == 200 and "access_token" in response.json():
- print("TOKEN: " + response.json()["access_token"])
- else:
- print(response.content)
- confirm_token_creation('сюда нужно ввести вывод с кода выше')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement