diff options
author | morpheus65535 <[email protected]> | 2022-11-07 13:06:49 -0500 |
---|---|---|
committer | morpheus65535 <[email protected]> | 2022-11-07 13:08:27 -0500 |
commit | bbe2483e21c2c1549ceeed16f021f9581b899f70 (patch) | |
tree | bcc2bef2f55789ec6e6c64809c07fb4f4d3d9c86 /libs/requests_oauthlib | |
parent | 708fbfcd8ec0620647975be39a1f6acbbf08f767 (diff) | |
download | bazarr-bbe2483e21c2c1549ceeed16f021f9581b899f70.tar.gz bazarr-bbe2483e21c2c1549ceeed16f021f9581b899f70.zip |
Updated vendored dependencies.
Diffstat (limited to 'libs/requests_oauthlib')
-rw-r--r-- | libs/requests_oauthlib/__init__.py | 2 | ||||
-rw-r--r-- | libs/requests_oauthlib/compliance_fixes/__init__.py | 2 | ||||
-rw-r--r-- | libs/requests_oauthlib/compliance_fixes/ebay.py | 23 | ||||
-rw-r--r-- | libs/requests_oauthlib/compliance_fixes/linkedin.py | 21 | ||||
-rw-r--r-- | libs/requests_oauthlib/oauth1_session.py | 2 | ||||
-rw-r--r-- | libs/requests_oauthlib/oauth2_session.py | 6 |
6 files changed, 32 insertions, 24 deletions
diff --git a/libs/requests_oauthlib/__init__.py b/libs/requests_oauthlib/__init__.py index a4e03a4e1..0d3e49f99 100644 --- a/libs/requests_oauthlib/__init__.py +++ b/libs/requests_oauthlib/__init__.py @@ -5,7 +5,7 @@ from .oauth1_session import OAuth1Session from .oauth2_auth import OAuth2 from .oauth2_session import OAuth2Session, TokenUpdated -__version__ = "1.3.0" +__version__ = "1.3.1" import requests diff --git a/libs/requests_oauthlib/compliance_fixes/__init__.py b/libs/requests_oauthlib/compliance_fixes/__init__.py index 02fa51201..0e8e3ac84 100644 --- a/libs/requests_oauthlib/compliance_fixes/__init__.py +++ b/libs/requests_oauthlib/compliance_fixes/__init__.py @@ -2,9 +2,9 @@ from __future__ import absolute_import from .facebook import facebook_compliance_fix from .fitbit import fitbit_compliance_fix -from .linkedin import linkedin_compliance_fix from .slack import slack_compliance_fix from .instagram import instagram_compliance_fix from .mailchimp import mailchimp_compliance_fix from .weibo import weibo_compliance_fix from .plentymarkets import plentymarkets_compliance_fix +from .ebay import ebay_compliance_fix diff --git a/libs/requests_oauthlib/compliance_fixes/ebay.py b/libs/requests_oauthlib/compliance_fixes/ebay.py new file mode 100644 index 000000000..4aa423b3f --- /dev/null +++ b/libs/requests_oauthlib/compliance_fixes/ebay.py @@ -0,0 +1,23 @@ +import json +from oauthlib.common import to_unicode + + +def ebay_compliance_fix(session): + def _compliance_fix(response): + token = json.loads(response.text) + + # eBay responds with non-compliant token types. + # https://developer.ebay.com/api-docs/static/oauth-client-credentials-grant.html + # https://developer.ebay.com/api-docs/static/oauth-auth-code-grant-request.html + # Modify these to be "Bearer". + if token.get("token_type") in ["Application Access Token", "User Access Token"]: + token["token_type"] = "Bearer" + fixed_token = json.dumps(token) + response._content = to_unicode(fixed_token).encode("utf-8") + + return response + + session.register_compliance_hook("access_token_response", _compliance_fix) + session.register_compliance_hook("refresh_token_response", _compliance_fix) + + return session diff --git a/libs/requests_oauthlib/compliance_fixes/linkedin.py b/libs/requests_oauthlib/compliance_fixes/linkedin.py deleted file mode 100644 index cd5b4ace3..000000000 --- a/libs/requests_oauthlib/compliance_fixes/linkedin.py +++ /dev/null @@ -1,21 +0,0 @@ -from json import loads, dumps - -from oauthlib.common import add_params_to_uri, to_unicode - - -def linkedin_compliance_fix(session): - def _missing_token_type(r): - token = loads(r.text) - token["token_type"] = "Bearer" - r._content = to_unicode(dumps(token)).encode("UTF-8") - return r - - def _non_compliant_param_name(url, headers, data): - token = [("oauth2_access_token", session.access_token)] - url = add_params_to_uri(url, token) - return url, headers, data - - session._client.default_token_placement = "query" - session.register_compliance_hook("access_token_response", _missing_token_type) - session.register_compliance_hook("protected_request", _non_compliant_param_name) - return session diff --git a/libs/requests_oauthlib/oauth1_session.py b/libs/requests_oauthlib/oauth1_session.py index aa17f28f3..88f2853ca 100644 --- a/libs/requests_oauthlib/oauth1_session.py +++ b/libs/requests_oauthlib/oauth1_session.py @@ -268,7 +268,7 @@ class OAuth1Session(requests.Session): :param url: The request token endpoint URL. :param realm: A list of realms to request access to. :param \*\*request_kwargs: Optional arguments passed to ''post'' - function in ''requests.Session'' + function in ''requests.Session'' :returns: The response in dict format. Note that a previously set callback_uri will be reset for your diff --git a/libs/requests_oauthlib/oauth2_session.py b/libs/requests_oauthlib/oauth2_session.py index eea4ac6fb..db4468089 100644 --- a/libs/requests_oauthlib/oauth2_session.py +++ b/libs/requests_oauthlib/oauth2_session.py @@ -189,6 +189,7 @@ class OAuth2Session(requests.Session): proxies=None, include_client_id=None, client_secret=None, + cert=None, **kwargs ): """Generic method for fetching an access token from the token endpoint. @@ -229,6 +230,10 @@ class OAuth2Session(requests.Session): `auth` tuple. If the value is `None`, it will be omitted from the request, however if the value is an empty string, an empty string will be sent. + :param cert: Client certificate to send for OAuth 2.0 Mutual-TLS Client + Authentication (draft-ietf-oauth-mtls). Can either be the + path of a file containing the private key and certificate or + a tuple of two filenames for certificate and key. :param kwargs: Extra parameters to include in the token request. :return: A token dict """ @@ -341,6 +346,7 @@ class OAuth2Session(requests.Session): auth=auth, verify=verify, proxies=proxies, + cert=cert, **request_kwargs ) |