mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-20 13:23:18 -07:00
Added dedicated SiCKRAGE section with API version and SSO login support (#1805)
Added migration code to migrate SickBeard section with fork sickrage-api to new SiCKRAGE section
This commit is contained in:
parent
9d64c2f478
commit
0acf78f196
91 changed files with 13436 additions and 35 deletions
33
libs/common/requests_oauthlib/compliance_fixes/facebook.py
Normal file
33
libs/common/requests_oauthlib/compliance_fixes/facebook.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
from json import dumps
|
||||
|
||||
try:
|
||||
from urlparse import parse_qsl
|
||||
except ImportError:
|
||||
from urllib.parse import parse_qsl
|
||||
|
||||
from oauthlib.common import to_unicode
|
||||
|
||||
|
||||
def facebook_compliance_fix(session):
|
||||
def _compliance_fix(r):
|
||||
# if Facebook claims to be sending us json, let's trust them.
|
||||
if "application/json" in r.headers.get("content-type", {}):
|
||||
return r
|
||||
|
||||
# Facebook returns a content-type of text/plain when sending their
|
||||
# x-www-form-urlencoded responses, along with a 200. If not, let's
|
||||
# assume we're getting JSON and bail on the fix.
|
||||
if "text/plain" in r.headers.get("content-type", {}) and r.status_code == 200:
|
||||
token = dict(parse_qsl(r.text, keep_blank_values=True))
|
||||
else:
|
||||
return r
|
||||
|
||||
expires = token.get("expires")
|
||||
if expires is not None:
|
||||
token["expires_in"] = expires
|
||||
token["token_type"] = "Bearer"
|
||||
r._content = to_unicode(dumps(token)).encode("UTF-8")
|
||||
return r
|
||||
|
||||
session.register_compliance_hook("access_token_response", _compliance_fix)
|
||||
return session
|
Loading…
Add table
Add a link
Reference in a new issue