Skip to content

Factor out basic authentication headers calculation #981

@nijel

Description

@nijel

Expected behaviour

There should be a single place to create HTTP authentication headers from KEY / SECRET.

Actual behaviour

There seem to be at least 7 implementations of this.

What are the steps to reproduce this issue?

Look around the code for code blocks like:

def auth_headers(self):
return {
"Authorization": b"Basic "
+ base64.b64encode("{}:{}".format(*self.get_key_and_secret()).encode())
}

def auth_headers(self):
return {
"Authorization": "Basic {}".format(
base64.urlsafe_b64encode(
"{}:{}".format(*self.get_key_and_secret()).encode()
)
)
}

Any other comments?

Probably the base class should get something like get_key_and_secret_basic_auth and it should be used in subclasses. Maybe even there could be a BaseOAuth2 subclass implementing auth_headers this way.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions