mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-14 18:47:09 -07:00
Update vendored requests-oauthlib to 1.3.1
This commit is contained in:
parent
501be2c479
commit
ebc9718117
7 changed files with 32 additions and 24 deletions
Binary file not shown.
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
23
libs/common/requests_oauthlib/compliance_fixes/ebay.py
Normal file
23
libs/common/requests_oauthlib/compliance_fixes/ebay.py
Normal file
|
@ -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
|
|
@ -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
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue