How to obtain the API tokenΒΆ

Firstly, you have to register our application in YooMoney using the link: click.

So, you will be redirected to the same page:

example of registration form

It goes without saying, we get the client_id after registration and then use YooMoneyAPI. Here is brief example how to obtain url to get special code

import asyncio

from glQiwiApi import YooMoneyAPI


async def get_url_to_auth() -> None:
    # Get a link for authorization, follow it if we get invalid_request or some kind of error
    # means either the scope parameter is incorrectly passed, you need to reduce the list of rights or try to recreate the application
    print(await YooMoneyAPI.build_url_for_auth(
        # For payments, account verification and payment history, you need to specify scope = ["account-info", "operation-history", "operation-details", "payment-p2p"]
        scope=["account-info", "operation-history"],
        client_id='ID received when registering the application above',
        redirect_uri='the link specified during registration above in the Redirect URI field'
    ))


asyncio.run(get_url_to_auth())

Tip

In the url you will see your code as a default param of GET request e.g. https://example.com/?code=bla-bla-bla

Now you need to get the temporary code and get the token as fast as possible using the YooMoneyAPI class method:

import asyncio

from glQiwiApi import YooMoneyAPI


async def get_token() -> None:
    print(await YooMoneyAPI.get_access_token(
        code='the code obtained from the link',
        client_id='Application ID received when registering the application above',
        redirect_uri='link provided during registration'
    ))


asyncio.run(get_token())