This commit is contained in:
yumoqing 2024-03-02 11:26:44 +08:00
parent 79c04c340e
commit e7420545b2

View File

@ -10,7 +10,6 @@ class OAuthClient:
self.data = desc.get('data') self.data = desc.get('data')
self.mapis = desc.get('mapis') self.mapis = desc.get('mapis')
self.mkeys = self.mapis.keys() self.mkeys = self.mapis.keys()
self.ac = ArgsConvert('${', '}') self.ac = ArgsConvert('${', '}')
async def __call__(self, mapi, params): async def __call__(self, mapi, params):
@ -22,16 +21,21 @@ class OAuthClient:
headers = {} headers = {}
for h in d.get('headers',{}): for h in d.get('headers',{}):
headers[h.get('name')] = h.get('value') headers[h.get('name')] = h.get('value')
mydata = {}
for p in d.get('data', {}):
mydata[p.get('name')] = p.get('value')
myparams = {} myparams = {}
for p in d.get('params', {}): for p in d.get('params', {}):
myparams[p.get('name')] = p.get('value') myparams[p.get('name')] = p.get('value')
url = d.get('url') url = d.get('url')
_params = self.datalize(myparams, params) _params = self.datalize(myparams, params)
_headers = self.datalize(headers, params) _headers = self.datalize(headers, params)
_data = self.datalize(data, params)
response_type = d.get('response_type', RESPONSE_JSON) response_type = d.get('response_type', RESPONSE_JSON)
hc = HttpClient() hc = HttpClient()
resp_data = await hc.request(url, method, response_type=response_type, resp_data = await hc.request(url, method, response_type=response_type,
params=_params, params=_params,
data=_data,
headers=_headers) headers=_headers)
if resp_data is None: if resp_data is None:
raise Exception(f'request error:{url=}\n{method=}\n{response_type=}\n{_params=}\n{_headers=}') raise Exception(f'request error:{url=}\n{method=}\n{response_type=}\n{_params=}\n{_headers=}')