requests-openapi icon indicating copy to clipboard operation
requests-openapi copied to clipboard

Any ideas about how to handle different API calls with different auth configuration?

Open SLdragon opened this issue 1 year ago • 2 comments

Seems currently we can only set requestor auth configurations for all APIs, any ideas about how to handle different API calls with different auth configuration?

import requests_openapi

# load spec from url
c = requests_openapi.Client().load_spec_from_url("https://raw.githubusercontent.com/master/examples/v3.0/petstore.yaml")

# custom session for auth or others
c.requestor # a instance of requests.Session, see https://requests.readthedocs.io/en/latest/user/advanced/#session-objects
# set update token
c.requestor.headers.update({"Authorization": "token"})

SLdragon avatar May 30 '24 09:05 SLdragon

Parameters starts with '_' or not found in openapi spec, will be passed through to the requesting. How about c.createPets(json={xx}, _headers={auth config in header}, _params={}, _cookies={or auth config in cookie})? @SLdragon

wy-z avatar May 30 '24 10:05 wy-z

Sure, good idea, will have a try, thank you!

SLdragon avatar May 31 '24 02:05 SLdragon