简体   繁体   English

APIError(code=-2014): API-key 格式无效

[英]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=..&timestamp=..不工作:[https://...]?signature=..&recvWindow=..&timestamp=..

working order: [https://...]?recvWindow =..&timestamp=..&signature=..工作顺序:[https://...]?recvWindow =..&timestamp=..&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.

相关问题 Binance Live Trading - APIError(code=-2014): API-key 格式无效 - Binance Live Trading - APIError(code=-2014): API-key format invalid Binance Future api:APIError(code=-2015):无效的 API 密钥、IP 或操作权限,请求 ip - Binance Future api : APIError(code=-2015): Invalid API-key, IP, or permissions for action, request ip APIError(code=-2015):API 密钥、IP 或使用 Binance 提款的操作权限无效 - APIError(code=-2015): Invalid API-key, IP, or permissions for action for Withdrawal using Binance 币安未来 API API 密钥、IP 或操作权限无效 - Binance future API Invalid API-key, IP, or permissions for action Tes.net Binance Future:无效的 API 密钥,IP,或操作权限 - Testnet Binance Future : Invalid API-key, IP, or permissions for action Binance api 期货错误:{"code":-2015,"msg":"Invalid API-key} using private_post_order_oco(但 ID 适用于其他一切) - Binance api futures error: {"code":-2015,"msg":"Invalid API-key} using private_post_order_oco (but ID works with everything else) 视觉客户端不支持api-key - vision-client doesn't supprt api-key Python-Binance.US api: APIError: (code=-1013): Filter failure: LOT_SIZE - Python-Binance.US api: APIError: (code=-1013): Filter failure: LOT_SIZE 币安 API:APIError(code=-1111):精度超过为该资产定义的最大值。 Python - Binance API: APIError(code=-1111): Precision is over the maximum defined for this asset. Python python-Binance api: APIError(code=-1013): Filter failure: LOT_SIZE - python-Binance api: APIError(code=-1013): Filter failure: LOT_SIZE
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM