mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-01-22 10:53:03 -08:00
0d1d2a3e6b
* Bump requests-oauthlib from 1.3.1 to 2.0.0 Bumps [requests-oauthlib](https://github.com/requests/requests-oauthlib) from 1.3.1 to 2.0.0. - [Release notes](https://github.com/requests/requests-oauthlib/releases) - [Changelog](https://github.com/requests/requests-oauthlib/blob/master/HISTORY.rst) - [Commits](https://github.com/requests/requests-oauthlib/compare/v1.3.1...v2.0.0) --- updated-dependencies: - dependency-name: requests-oauthlib dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * Update requests-oauthlib==2.0.0 --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> [skip ci]
24 lines
846 B
Python
24 lines
846 B
Python
"""
|
|
The Fitbit API breaks from the OAuth2 RFC standard by returning an "errors"
|
|
object list, rather than a single "error" string. This puts hooks in place so
|
|
that oauthlib can process an error in the results from access token and refresh
|
|
token responses. This is necessary to prevent getting the generic red herring
|
|
MissingTokenError.
|
|
"""
|
|
|
|
from json import loads, dumps
|
|
|
|
|
|
def fitbit_compliance_fix(session):
|
|
def _missing_error(r):
|
|
token = loads(r.text)
|
|
if "errors" in token:
|
|
# Set the error to the first one we have
|
|
token["error"] = token["errors"][0]["errorType"]
|
|
r._content = dumps(token).encode()
|
|
return r
|
|
|
|
session.register_compliance_hook("access_token_response", _missing_error)
|
|
session.register_compliance_hook("refresh_token_response", _missing_error)
|
|
return session
|