HEX
Server: LiteSpeed
System: Linux server.nevid-deploma.com 4.18.0-553.111.1.lve.el8.x86_64 #1 SMP Fri Mar 13 13:42:17 UTC 2026 x86_64
User: smilepac (1037)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //opt/cppython/lib/python3.8/site-packages/requests_oauthlib/compliance_fixes/ebay.py
import json


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 = fixed_token.encode()

        return response

    session.register_compliance_hook("access_token_response", _compliance_fix)
    session.register_compliance_hook("refresh_token_response", _compliance_fix)

    return session