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

[script.module.requests_oauthlib@matrix] 1.3.1+matrix.1 #2545

Merged
merged 1 commit into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 0 additions & 58 deletions script.module.requests_oauthlib/README.rst

This file was deleted.

38 changes: 18 additions & 20 deletions script.module.requests_oauthlib/addon.xml
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.module.requests_oauthlib" name="requests_oauthlib" version="1.3.0+matrix.2" provider-name="Ib Lundgren">
<requires>
<import addon="xbmc.python" version="3.0.0"/>
<import addon="script.module.oauthlib" version="3.1.0+matrix.1"/>
<import addon="script.module.requests" version="2.22.0+matrix.1"/>
</requires>
<extension point="xbmc.python.module" library="lib" />
<extension point="xbmc.addon.metadata">
<platform>all</platform>
<language></language>
<summary lang="en_GB">This project provides first-class OAuth library support for Requests.</summary>
<description lang="en_GB">This project provides first-class OAuth library support for Requests.</description>
<disclaimer lang="en_GB">This project provides first-class OAuth library support for Requests.</disclaimer>
<license>ISC</license>
<website>https://pypi.org/project/requests-oauthlib</website>
<source>https://github.com/requests/requests-oauthlib</source>
<assets>
<icon>icon.png</icon>
</assets>
</extension>
<addon id="script.module.requests_oauthlib" name="requests-oauthlib" version="1.3.1+matrix.1" provider-name="requests">
<requires>
<import addon="xbmc.python" version="3.0.0" />
<import addon="script.module.oauthlib" version="3.2.2" />
<import addon="script.module.requests" version="2.31.0" />
</requires>
<extension point="xbmc.python.module" library="lib" />
<extension point="xbmc.addon.metadata">
<summary lang="en_GB">OAuthlib authentication support for Requests</summary>
<description lang="en_GB">OAuthlib authentication support for Requests</description>
<license>ISC</license>
<platform>all</platform>
<website>https://github.com/requests/requests-oauthlib</website>
<source>https://github.com/requests/requests-oauthlib</source>
<assets>
<icon>resources/icon.png</icon>
</assets>
</extension>
</addon>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from .oauth2_auth import OAuth2
from .oauth2_session import OAuth2Session, TokenUpdated

__version__ = "1.3.0"
__version__ = "1.3.1"

import requests

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

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
Original file line number Diff line number Diff line change
@@ -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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def fetch_request_token(self, url, realm=None, **request_kwargs):
: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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ def fetch_token(
proxies=None,
include_client_id=None,
client_secret=None,
cert=None,
**kwargs
):
"""Generic method for fetching an access token from the token endpoint.
Expand Down Expand Up @@ -229,6 +230,10 @@ def fetch_token(
`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
"""
Expand Down Expand Up @@ -341,6 +346,7 @@ def fetch_token(
auth=auth,
verify=verify,
proxies=proxies,
cert=cert,
**request_kwargs
)

Expand Down
Loading