E
E
eifory2018-11-07 18:01:28
Python
eifory, 2018-11-07 18:01:28

Yandex Connect. How to make a POST request? And get json?

https://tech.yandex.ru/oauth/doc/dg/reference/auto...
Here's what's in the documentation:
POST /token HTTP/1.1
Host: oauth.yandex.ru
Content-type: application/x-www- form-urlencoded
Content-Length: <request body length>
[Authorization: Basic <client_id:client_secret encoded string>]
grant_type=authorization_code
& code=<authorization code>
Response should be json. I have code.
So far I have come up with this code:

import requests
import json
headers = {'Content-type': 'application/x-www-form-urlencoded'}
data = {'grant_type': 'authorization_code', 'code':'xxxxxxx'}
response = requests.post('http://oauth.yandex.ru', headers = headers, data=data)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question