How to use the mkmsdk.MKMOAuth1.MKMOAuth1 function in mkmsdk

To help you get started, we’ve selected a few mkmsdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github evonove / mkm-sdk / tests / tests_integration / test_oauth.py View on Github external
def test_widget_app_oauth1_is_correct():
    """Verifies if response from backend is positive using custom Client."""
    url = "https://sandbox.cardmarket.com/ws/v1.1/output.json/games"
    auth = MKMOAuth1(
        os.environ.get("MKM_APP_TOKEN"),
        client_secret=os.environ.get("MKM_APP_SECRET"),
        resource_owner_key=os.environ.get("MKM_ACCESS_TOKEN"),
        resource_owner_secret=os.environ.get("MKM_ACCESS_TOKEN_SECRET"),
        realm=url,
        client_class=MKMClient,
    )

    r = requests.get(url, auth=auth)

    assert r.status_code == 200
github evonove / mkm-sdk / tests / tests_integration / test_oauth.py View on Github external
def test_account_entity_is_as_expected():
    """Verifies the account entity received is as expected."""
    url = "https://sandbox.cardmarket.com/ws/v1.1/output.json/account"
    auth = MKMOAuth1(
        os.environ.get("MKM_APP_TOKEN"),
        client_secret=os.environ.get("MKM_APP_SECRET"),
        resource_owner_key=os.environ.get("MKM_ACCESS_TOKEN"),
        resource_owner_secret=os.environ.get("MKM_ACCESS_TOKEN_SECRET"),
        realm=url,
    )

    r = requests.get(url, auth=auth)

    json_response = r.json()

    received_first_name = json_response["account"]["name"]["firstName"]
    received_last_name = json_response["account"]["name"]["lastName"]

    assert r.status_code == 200
    assert received_first_name
github evonove / mkm-sdk / tests / tests_integration / test_oauth.py View on Github external
def test_dedicated_app_oauth1_is_correct():
    """Verifies if response from backend is positive using custom OAuth header."""
    url = "https://sandbox.cardmarket.com/ws/v1.1/output.json/games"
    auth = MKMOAuth1(
        os.environ.get("MKM_APP_TOKEN"),
        client_secret=os.environ.get("MKM_APP_SECRET"),
        resource_owner_key=os.environ.get("MKM_ACCESS_TOKEN"),
        resource_owner_secret=os.environ.get("MKM_ACCESS_TOKEN_SECRET"),
        realm=url,
    )

    r = requests.get(url, auth=auth)

    assert r.status_code == 200
github evonove / mkm-sdk / tests / tests_integration / test_oauth.py View on Github external
def test_oauth_is_received():
    """Verifies if OAuth1 is received."""
    url = "https://sandbox.cardmarket.com/ws/v1.1/output.json/games"
    auth = MKMOAuth1(
        os.environ.get("MKM_APP_TOKEN"),
        client_secret=os.environ.get("MKM_APP_SECRET"),
        resource_owner_key=os.environ.get("MKM_ACCESS_TOKEN"),
        resource_owner_secret=os.environ.get("MKM_ACCESS_TOKEN_SECRET"),
        realm=url,
    )

    assert isinstance(auth, OAuth1)
github evonove / mkm-sdk / mkmsdk / api.py View on Github external
"""

        app_token = app_token if app_token is not None else get_mkm_app_token()
        app_secret = app_secret if app_secret is not None else get_mkm_app_secret()
        access_token = access_token if access_token is not None else get_mkm_access_token()
        access_token_secret = access_token_secret if access_token_secret is not None else get_mkm_access_token_secret()

        # If access_token and access_token_secret are empty strings a personalized OAuth1 Client is used.
        # This is done because that would mean the user is using a Widget Application and having empty strings
        # as tokens causes issues with the default Client
        if not access_token and not access_token_secret:
            client = MKMClient
        else:
            client = Client

        return MKMOAuth1(
            app_token,
            client_secret=app_secret,
            resource_owner_key=access_token,
            resource_owner_secret=access_token_secret,
            client_class=client,
            realm=url,
        )
github evonove / mkm-sdk / mkmsdk / MKMOAuth1.py View on Github external
def __call__(self, r):
        r = super(MKMOAuth1, self).__call__(r)

        r.prepare_headers(r.headers)

        correct_signature = self.decode_signature(r.headers)

        r.headers.__setitem__("Authorization", correct_signature)
        r.url = to_native_string(r.url)
        return r