[英]APIError(code=-2014): API-key format invalid
call to action!呼吁采取行动!
I am struggling in this:我在这方面苦苦挣扎:
APIError(code=-2014): API-key format invalid APIError(code=-2014): API-key 格式无效
Any suggestion?有什么建议吗? Many thanks
非常感谢
# Import libraries
import configparser
from binance.client import Client
# Load keys from config file
config = configparser.ConfigParser()
config.read_file(open(r'C:\\*****my_path****\\secret.cfg'))
test_api_key = config.get('BINANCE', 'TEST_API_KEY')
test_secret_key = config.get('BINANCE', 'TEST_SECRET_KEY')
#ping the server
client.ping()
#get the server time
time_res = client.get_server_time()
# Getting account info
info = client.get_account()
# Get current products
products = client.get_products()
#Get all coin info
info = client.get_all_coins_info()
print(info)
--- EDIT: ERROR OUTPUT --- 编辑:错误 OUTPUT
Here the error message in output:这里是 output 中的错误消息:
[Running] python -u "c:\Users\ssida\OneDrive\Documenti\GitHub\AI7XF205SS\getting_account_info.py"
Traceback (most recent call last):
File "c:\Users\ssida\OneDrive\Documenti\GitHub\AI7XF205SS\getting_account_info.py", line 16, in <module>
info = client.get_account() # Getting account info
File "C:\Users\ssida\anaconda3\lib\site-packages\binance\client.py", line 1822, in get_account
return self._get('account', True, data=params)
File "C:\Users\ssida\anaconda3\lib\site-packages\binance\client.py", line 292, in _get
return self._request_api('get', path, signed, version, **kwargs)
File "C:\Users\ssida\anaconda3\lib\site-packages\binance\client.py", line 242, in _request_api
return self._request(method, uri, signed, **kwargs)
File "C:\Users\ssida\anaconda3\lib\site-packages\binance\client.py", line 237, in _request
return self._handle_response()
File "C:\Users\ssida\anaconda3\lib\site-packages\binance\client.py", line 285, in _handle_response
raise BinanceAPIException(self.response)
binance.exceptions.BinanceAPIException: APIError(code=-2014): API-key format invalid.
[Done] exited with code=1 in 1.952 seconds
HEre the snapshot of the error message showed me by python terminal > Pylance explain to me that is related on reportMIssing Imports (that i dunno whats mean but ok!)这里错误消息的快照由 python 终端向我显示 > Pylance 向我解释与 reportMissing Imports 相关的内容(我不知道这是什么意思,但没关系!)
I spent few hours debugging right "signature" generation, checking time sync and getting such message.我花了几个小时调试正确的“签名”生成,检查时间同步并获取此类消息。 found that it is required to put signature as last api query param:
发现需要将签名作为最后一个 api 查询参数:
not working: [https://...]?signature=..&recvWindow=..×tamp=..不工作:[https://...]?signature=..&recvWindow=..×tamp=..
working order: [https://...]?recvWindow =..×tamp=..&signature=..工作顺序:[https://...]?recvWindow =..×tamp=..&signature=..
Most likely 'TEST_API_KEY' or 'TEST_SECRET_KEY' are wrong or have the wrong format.很可能“TEST_API_KEY”或“TEST_SECRET_KEY”是错误的或格式错误。 I had the same problem because the keys were stored in the.env file with quotes
我遇到了同样的问题,因为密钥存储在带有引号的 .env 文件中
TEST_API_KEY="xxxxxxxxxxxxxxxx"
and after removing quotes, it worked.删除引号后,它起作用了。
TEST_API_KEY=xxxxxxxxxxxxxxxx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.