C
C
che_aa2021-01-25 14:41:46
YuMoney
che_aa, 2021-01-25 14:41:46

How to get a YooMoney token (Yandex money)?

I do everything by api.
The essence of the problem: Yandex Money does not send a token to my server.

API
https://yoomoney.ru/docs/wallet/using-api/authoriz...

That is, I send a redirect to the documentation, but I do not receive an http request.
The code:
from flask import Flask, request, redirect
import logging
logging.basicConfig(filename="logs.log", level=logging.INFO)
app = Flask(__name__)

@app.route('/')
def get_onetime_code():
    logging.info(request.url)
    data = request.args
    code = data['code']
    client_id = 'client'
    return redirect('https://yoomoney.ru/oauth/token?code={}&client_id={}&grant_type=authorization_code&redirect_uri=http://me.pythonanywhere.com/reg'.format(code, client_id), code=302)

@app.route('/reg')
def get_code():
    logging.info(request.url)
    data = request.args
    f = open('data.txt', 'w')
    f.write(str(data['code']))
    f.close()
    return 'ok'
if __name__ == '__main__':
    app.run(debug = True)

Logs:
INFO:root:http://me.pythonanywhere.com/?code=code
While the temporary code successfully arrives at the server.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question