Skip to content

Commit 06489dc

Browse files
committed
Expose missing classes
1 parent 6eac255 commit 06489dc

File tree

5 files changed

+19
-3
lines changed

5 files changed

+19
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
## [Unreleased]
88
### Added
99
- Adding explicit support for Python `3.12`.
10+
- Publicly expose `requests_auth.SupportMultiAuth`, allowing multiple authentication support for every `requests` authentication class that exists.
11+
- Publicly expose `requests_auth.TokenMemoryCache`, allowing to create custom Oauth2 token cache based on this default implementation.
1012

1113
### Changed
1214
- Except for `requests_auth.testing`, only direct access via `requests_auth.` was considered publicly exposed. This is now explicit, as inner packages are now using private prefix (`_`).

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,17 @@ oauth2 = OAuth2Implicit('https://www.example.com')
698698
requests.get('https://www.example.com', auth=api_key + oauth2)
699699
```
700700

701+
This is supported on every authentication class exposed by `requests_auth`, but you can also enable it on your own authentication classes by using `requests_auth.SupportMultiAuth` as in the following sample:
702+
703+
```python
704+
from requests_auth import SupportMultiAuth
705+
# TODO Import your own auth here
706+
from my_package import MyAuth
707+
708+
class MyMultiAuth(MyAuth, SupportMultiAuth):
709+
pass
710+
```
711+
701712
## Available pytest fixtures
702713

703714
Testing the code using `requests_auth` authentication classes can be achieved using provided [`pytest`][6] fixtures.

requests_auth/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
HeaderApiKey,
44
QueryApiKey,
55
NTLM,
6+
SupportMultiAuth,
67
)
78
from requests_auth._oauth2.common import OAuth2
89
from requests_auth._oauth2.authorization_code import (
@@ -28,7 +29,7 @@
2829
OAuth2ResourceOwnerPasswordCredentials,
2930
OktaResourceOwnerPasswordCredentials,
3031
)
31-
from requests_auth._oauth2.tokens import JsonTokenFileCache
32+
from requests_auth._oauth2.tokens import JsonTokenFileCache, TokenMemoryCache
3233
from requests_auth._errors import (
3334
GrantNotProvided,
3435
TimeoutOccurred,
@@ -59,7 +60,9 @@
5960
"OAuth2ResourceOwnerPasswordCredentials",
6061
"OktaResourceOwnerPasswordCredentials",
6162
"NTLM",
63+
"SupportMultiAuth",
6264
"JsonTokenFileCache",
65+
"TokenMemoryCache",
6366
"GrantNotProvided",
6467
"TimeoutOccurred",
6568
"AuthenticationFailed",

requests_auth/testing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def create_token(expiry: Optional[datetime.datetime]) -> str:
2020

2121

2222
@pytest.fixture
23-
def token_cache():
23+
def token_cache() -> requests_auth.TokenMemoryCache:
2424
yield requests_auth.OAuth2.token_cache
2525
requests_auth.OAuth2.token_cache.clear()
2626

tests/test_json_token_file_cache.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
@pytest.fixture
11-
def token_cache(request):
11+
def token_cache(request) -> requests_auth.JsonTokenFileCache:
1212
_token_cache = requests_auth.JsonTokenFileCache(request.node.name + ".cache")
1313
yield _token_cache
1414
_token_cache.clear()

0 commit comments

Comments
 (0)