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

Add support for Bearer token strings for auth #282

Merged
merged 2 commits into from
Jun 27, 2022
Merged

Conversation

leplatrem
Copy link
Contributor

No description provided.

Comment on lines +8 to 9
import kinto_http
from kinto_http import utils
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason in particular you chose not to import BearerTokenAuth from kinto_http when we're already importing utils? Not a big deal, just curious

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't really think about it. I had kinto_http.BearerTokenAuth in mind and imported the top module to get it...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah well, my subconscious was probably aware that it would raise:

ImportError: cannot import name 'BearerTokenAuth' from partially initialized module 'kinto_http' (most likely due to a circular import) (/Users/mathieu/Code/Mozilla/kinto-http.py/kinto_http/__init__.py)

🤣



def test_auth_can_be_an_arbitrary_string(session_setup: Tuple[MagicMock, Session]):
session = create_session(auth="Some abcdef")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised this is supported by requests. Is this actually a valid form of authentication?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at https://requests.readthedocs.io/en/latest/_modules/requests/models/#PreparedRequest.prepare_auth

Auth can only be a tuple or a callable.

Will fix code and tests

@leplatrem leplatrem merged commit 902a0d7 into master Jun 27, 2022
@leplatrem leplatrem deleted the add-auth-constructor branch June 27, 2022 10:47
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

Successfully merging this pull request may close these issues.

None yet

2 participants