You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As stated in the requests document, user may pass a sub class of AuthBase as the auth parameter. This is very useful when the authentication is a little bit more complicated than passing the session token or basic auth.
I guess this can be worked around by allowing user to pass a custom function which return AuthBase subclass? Something similar to the below.
from requests.auth import AuthBase
class PizzaAuth(AuthBase):
"""Attaches HTTP Pizza Authentication to the given Request object."""
def __init__(self, username):
# setup any auth-related data here
self.username = username
def __call__(self, r):
# modify and return the request
r.headers['X-Pizza'] = self.username
return r
def prepare_auth(**kwargs):
username = kwargs['username']
return PizzaAuth(username)
I hope this makes sense ?
I do have a fix which can be submitted shortly. Let me know what you think.
The text was updated successfully, but these errors were encountered:
In case anyone is interested, I've a branch for the above feature.
The branch allows us to use a custom function as request.auth.
It may be installed via pip install git+https://github.com/sohoffice/tavern.git@douglas/auth-function
As stated in the requests document, user may pass a sub class of AuthBase as the auth parameter. This is very useful when the authentication is a little bit more complicated than passing the session token or basic auth.
I guess this can be worked around by allowing user to pass a custom function which return AuthBase subclass? Something similar to the below.
In the
security.py
, the caller can do the belowI hope this makes sense ?
I do have a fix which can be submitted shortly. Let me know what you think.
The text was updated successfully, but these errors were encountered: