Py学习  »  Python

Python urllib3似乎没有发送字段数据

pee2pee • 3 年前 • 1385 次点击  

我试图在这里使用身份验证: https://api.graphnethealth.com/system-auth 使用Python urllib3并具有以下功能

import urllib3
http = urllib3.PoolManager()
resp = http.request(
        "POST",
        "https://core.syhapp.com/hpca/oauth/token",
        headers={
            "Content-Type": "application/x-www-form-urlencoded"
        },
        fields={
            "grant_type": "client_credentials",
            "client_id": "YYYYYYYYY",
            "client_secret": "XXXXXXXXX"
        }
    )
print(resp.data)

我说这话是错的 grant_type 尚未发送。

b'{\r\n  "error": {\r\n    "code": "400",\r\n    "message": "Validation Errors",\r\n    "target": "/oauth/token",\r\n    "details": [\r\n      {\r\n        "message": "grant_type is required",\r\n        "target": "GrantType"\r\n      },\r\n      {\r\n        "message": "Value should be one of the following password,refresh_token,trusted_token,handover_token,client_credentials,pin",\r\n        "target": "GrantType"\r\n      }\r\n    ]\r\n  }\r\n}'

有什么建议吗?

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/131216
 
1385 次点击  
文章 [ 2 ]  |  最新文章 3 年前