HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/aigenerator/venv/lib/python3.12/site-packages/social_core/backends/taobao.py
from .oauth import BaseOAuth2


class TAOBAOAuth(BaseOAuth2):
    """Taobao OAuth authentication mechanism"""

    name = "taobao"
    ID_KEY = "taobao_user_id"
    ACCESS_TOKEN_METHOD = "POST"
    AUTHORIZATION_URL = "https://oauth.taobao.com/authorize"
    ACCESS_TOKEN_URL = "https://oauth.taobao.com/token"

    def user_data(self, access_token, *args, **kwargs):
        """Return user data provided"""
        try:
            return self.get_json(
                "https://eco.taobao.com/router/rest",
                params={
                    "method": "taobao.user.get",
                    "fomate": "json",
                    "v": "2.0",
                    "access_token": access_token,
                },
            )
        except ValueError:
            return None

    def get_user_details(self, response):
        """Return user details from Taobao account"""
        return {"username": response.get("taobao_user_nick")}