diff --git a/doc/changelog.d/640.fixed.md b/doc/changelog.d/640.fixed.md new file mode 100644 index 00000000..ed73d422 --- /dev/null +++ b/doc/changelog.d/640.fixed.md @@ -0,0 +1 @@ +Support requests-auth 8.0.0 \ No newline at end of file diff --git a/poetry.lock b/poetry.lock index 5853b959..0a1b6b32 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1394,20 +1394,20 @@ use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] [[package]] name = "requests-auth" -version = "7.0.0" +version = "8.0.0" description = "Authentication for Requests" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "requests_auth-7.0.0-py3-none-any.whl", hash = "sha256:a6ee7209435a1489d1f2a9b0e855e1f3d87bbae5bc4acda0c27bdac49aa74fd4"}, - {file = "requests_auth-7.0.0.tar.gz", hash = "sha256:8a9d5a185905d13bdba03de3e52c0c7a9d8658b5f43ff6de462fbeb2df91e9c9"}, + {file = "requests_auth-8.0.0-py3-none-any.whl", hash = "sha256:7faf0c58cadb61d2398fed9ea412a38641d70a856b1db25db281f9057194f1ca"}, + {file = "requests_auth-8.0.0.tar.gz", hash = "sha256:ca2f2126d8a41e1d1615faa8cf8d5d62ea01d705f9ee99f470b9a44abd5dee82"}, ] [package.dependencies] requests = "==2.*" [package.extras] -testing = ["pyjwt (==2.*)", "pytest-cov (==4.*)", "pytest-responses (==0.5.*)"] +testing = ["pyjwt (==2.*)", "pytest-cov (==5.*)", "pytest-responses (==0.5.*)"] [[package]] name = "requests-kerberos" @@ -1876,4 +1876,4 @@ oidc = ["keyring", "requests_auth"] [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "22dbadc1bf0bf3fdca2e80a2d4f158711c742a691b744efca053f89be225b780" +content-hash = "005b4ddc0722e63430831319569c1fcd5daefa6b65969613ab5e01e4073e3da7" diff --git a/pyproject.toml b/pyproject.toml index 6364a41f..59a0304e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,7 +46,7 @@ pyparsing = "^3.0.8" python-dateutil ="^2.9" # Packages for oidc extra -requests_auth = { version = ">=6,<9", optional = true } +requests_auth = { version = "^8.0.0", optional = true } keyring = { version = ">=22,<26", optional = true } # Packages for linux-kerberos extra diff --git a/src/ansys/openapi/common/_oidc.py b/src/ansys/openapi/common/_oidc.py index d2f6b380..70008d01 100644 --- a/src/ansys/openapi/common/_oidc.py +++ b/src/ansys/openapi/common/_oidc.py @@ -25,14 +25,12 @@ import keyring import requests from requests.models import CaseInsensitiveDict -from requests_auth import ( # type: ignore[import-untyped] +from requests_auth import ( # type: ignore[import-untyped, unused-ignore] InvalidGrantRequest, + OAuth2, OAuth2AuthorizationCodePKCE, ) -# This import is optional and has missing type hints, so use a broad ignore statement -from requests_auth.authentication import OAuth2 # type: ignore - from ._logger import logger from ._util import ( RequestsConfiguration, @@ -149,10 +147,11 @@ def get_session_with_provided_token(self, refresh_token: str) -> requests.Sessio except InvalidGrantRequest as excinfo: logger.debug(str(excinfo)) raise ValueError("The provided refresh token was invalid, please request a new token.") - with OAuth2.token_cache.forbid_concurrent_missing_token_function_call: + # noinspection PyProtectedMember + with OAuth2.token_cache._forbid_concurrent_missing_token_function_call: # type: ignore[unused-ignore] # If we were provided with a new refresh token it's likely that the Identity # Provider is configured to rotate refresh tokens. Store the new one and - # discard the old one. Otherwise use the existing refresh token. + # discard the old one. Otherwise, use the existing refresh token. if new_refresh_token is not None: refresh_token = new_refresh_token # noinspection PyProtectedMember diff --git a/src/ansys/openapi/common/_session.py b/src/ansys/openapi/common/_session.py index 4e0b2e18..9a0efaea 100644 --- a/src/ansys/openapi/common/_session.py +++ b/src/ansys/openapi/common/_session.py @@ -54,7 +54,7 @@ try: # noinspection PyUnresolvedReferences import keyring - import requests_auth # type: ignore[import-untyped] # noqa: F401 + import requests_auth # type: ignore[import-untyped, unused-ignore] # noqa: F401 from ._oidc import OIDCSessionFactory except ImportError: diff --git a/tests/test_oidc.py b/tests/test_oidc.py index dd7f6fc6..8329208a 100644 --- a/tests/test_oidc.py +++ b/tests/test_oidc.py @@ -27,7 +27,7 @@ from covertable import make import pytest import requests -from requests_auth.authentication import OAuth2 +from requests_auth import OAuth2 import requests_mock from ansys.openapi.common import ApiClientFactory