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

Factor out basic authentication headers calculation #981

Open
nijel opened this issue Jan 6, 2025 · 0 comments
Open

Factor out basic authentication headers calculation #981

nijel opened this issue Jan 6, 2025 · 0 comments

Comments

@nijel
Copy link
Member

nijel commented Jan 6, 2025

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.

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

No branches or pull requests

1 participant