Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
SLdragon opened this issue May 30, 2024 · 2 comments

Comments

@SLdragon
Copy link

SLdragon commented May 30, 2024

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"})
@wy-z
Copy link
Owner

wy-z commented May 30, 2024

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

@SLdragon
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants