Skip to content

methods

OAuthMethods

get_tokens_by_code staticmethod

Python
1
get_tokens_by_code(client_id: str, client_secret: str, code: int) -> dict

noqa: E501

Get access and refresh token by code https://yandex.ru/dev/market/partner-api/doc/ru/concepts/how-to-use-refresh-token#get-tokens :param client_id: app client id :param client_secret: app client secret :param code: code, that you got after _auth :return: dict with access_token, expires_in, token_type and refresh_token keys

Source code in marketplace_apis/yandex/oauth/methods.py
Python
44
45
46
47
48
49
50
51
52
53
54
55
56
@staticmethod
def get_tokens_by_code(client_id: str, client_secret: str, code: int) -> dict:
    """# noqa: E501
    Get access and refresh token by code
    https://yandex.ru/dev/market/partner-api/doc/ru/concepts/how-to-use-refresh-token#get-tokens
    :param client_id: app client id
    :param client_secret: app client secret
    :param code: code, that you got after _auth
    :return: dict with access_token, expires_in, token_type and refresh_token keys
    """
    return OAuthMethods._get_tokens(
        client_id, client_secret, code, "authorization_code", "code"
    )

get_tokens_by_refresh staticmethod

Python
1
get_tokens_by_refresh(client_id: str, client_secret: str, refresh_token: str) -> dict

Get new access and refresh token by old refresh token :param client_id: app client id :param client_secret: app client secret :param refresh_token: refresh token :return: dict with access_token, expires_in, token_type and refresh_token keys

Source code in marketplace_apis/yandex/oauth/methods.py
Python
58
59
60
61
62
63
64
65
66
67
68
69
70
71
@staticmethod
def get_tokens_by_refresh(
    client_id: str, client_secret: str, refresh_token: str
) -> dict:
    """
    Get new access and refresh token by old refresh token
    :param client_id: app client id
    :param client_secret: app client secret
    :param refresh_token: refresh token
    :return: dict with access_token, expires_in, token_type and refresh_token keys
    """
    return OAuthMethods._get_tokens(
        client_id, client_secret, refresh_token, "refresh_token"
    )