Open batandwa opened 2 years ago
I am willing to contribute to this...
Custom authentication here means special HTTP headers sent with the request? Or something more sophisticated?
Whatever the request module allows in the auth parameter when executing request()
On the other hand... That may lead to the request module being an irreplaceable dependency.
On the other hand... That may lead to the request module being an irreplaceable dependency.
That's fine, it is already a required dependency.
Whatever the request module allows in the auth parameter when executing
request()
The docs say:
auth – (optional) Auth tuple to enable Basic/Digest/Custom HTTP Auth.
So I guess this means you get a tuple like (username, password)
passed there and requests takes care of creating the right header. Should be easy to allow for this. However, for "custom" authentication, you can anyway just set a HTTP header. Granted, for Basic auth, username/password is convenient, and for Digest auth it's essential.
..and i read your request again -- in this case, you probably would like to have a way of adding all the AWS settings and then pass the AWSRequestsAuth()
object to the auth, so just configuring username/password in the YAML is not enough.
One way to do it would be to subclass jobs.UrlJob
as done in share/urlwatch/examples/hooks.py.example
:
class CustomLoginJob(jobs.UrlJob):
"""Custom login for my webpage"""
__kind__ = 'aws-login'
__required__ = ('aws_access_key', 'aws_secret_access_key', ...)
def retrieve(self, job_state):
... # TODO: Make request, return response, use self.aws_access_key, etc...
I would like create a custom hook that sets custom authentication that is compatible request module.
For context... I thought this would be useful when I was doing AWS v4 signing using the aws_request_auth module.