我如何使用此信息检索 python 中的返回数据

how do I use this information to retrieve the returned data in python

我正在尝试使用 auth0,我对如何在 python 中 运行 这个 post 请求有点困惑。使用此信息在 python/flask 中会是什么样子?

POST https://YOUR_DOMAIN/oauth/token
Content-Type: application/x-www-form-urlencoded

audience=API_IDENTIFIER&grant_type=client_credentials&client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET

它应该 return 这个:

HTTP/1.1 200 OK
Content-Type: application/json
{
  "access_token":"eyJz93a...k4laUWw",
  "token_type":"Bearer",
  "expires_in":86400
}

如何在 python 中获取此信息?

这是我正在使用的代码。它在 postman 中有效,但在我的浏览器中出现此错误:

socket.gaierror
socket.gaierror: [Errno -2] Name or service not known
@app.route('/login')
def get_token():
    conn = http.client.HTTPSConnection("")

    payload = {'grant_type':'client_credentials',
                'client_id':'JXHzBwF6DPiXU2fBjPe1Nd7bYPC6vZ0o',
                'client_secret':'aSEqerZw31L19r9QzdcbrLBIVY3i2WD3U6Cd2kBwY0MIKWJrlMNny6A7nySzlSS1',
                'audience':'image'
                }
    headers = { 'content-type': "application/x-www-form-urlencoded" }

    conn.request("POST", "https://dcadventuresonline.us.auth0.com/oauth/token", headers, payload)

    res = conn.getresponse()
    data = res.read()


    print(data)
    return data
import requests


def get_token():
    payload = {
        "grant_type": "client_credentials",
        "client_id": "JXHzBwF6DPiXU2fBjPe1Nd7bYPC6vZ0o",
        "client_secret": "aSEqerZw31L19r9QzdcbrLBIVY3i2WD3U6Cd2kBwY0MIKWJrlMNny6A7nySzlSS1",
        "audience": "image",
    }
    headers = {"content-type": "application/x-www-form-urlencoded"}
    url = "https://dcadventuresonline.us.auth0.com/oauth/token"

    response = requests.post(url=url, headers=headers, data=payload)
    return response.json()