Answer the question
In order to leave comments, you need to log in
How to make a verification signature?
Please help me figure it out. I recently started to study the anypay.io API and got stuck at the very start :) When reproducing the code:
import requests
import hashlib
from data import ANYPAY_API_ID, ANYPAY_API_KEY
import json
sign = hashlib.sha256(f'balance{ANYPAY_API_ID()}{ANYPAY_API_KEY()}'.encode())
responce = requests.get(f"https://anypay.io/api/balance/{ANYPAY_API_ID()}", params=str(sign))
print(responce.json())
{'error': {'code': '102', 'message': 'Invalid sign'}}
Answer the question
In order to leave comments, you need to log in
Have you looked in the console to see what str(hashlib.sha256(...)) will output?
And it will display something like: '<sha256 HASH object @ 0x6ffffebcc88>'
As written above, you need to sign.digest() or sign.hexdigest(), depending on what form the api wants.
Well, it’s unlikely that a naked signature is put in POST, judging by the dock, you need something like:
requests.get(..., params={"sign":sign.hexdigest()})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question