Invalid Api-key, IP or premision for action when using futures testnet

I have been trying to get a futures testnet API to work but I can’t seem to. No already open topic here explain well enough how to fix it. A good example is this guy ( How to make a futures testnet order via Python?) he had the exact same problem but the solution was explained very badly.

My code:
################################
import os

from binance.client import Client

api_key = os.environ[‘api_secret’]
api_secret = os.environ[‘api_key’]

client = Client(api_key, api_secret, testnet=True)

client.API_URL = ‘https://testnet.binancefuture.{}/fapi’

print(client.get_account())
################################

I would be very grateful for any help. Thanks in advance!

Hello,

From your code example, I can’t tell what’s the library you’re using and what’s the code written behind it, this should be looked up locally to understand how a request is build.

Unfortunately we can’t be active on supporting programming questions and look into libraries beyond what’s official from Binance · GitHub, however for the error message, we have this FAQ that has the most common reasons: why do I see this error "Invalid API-key, IP, or permissions for action." - #2.

Maybe you’re using the incorrect API Key? Be aware the keys for testnet.binancefuture.com is different. More info: Binance Testnet environments

I’m using the library installed by using “pip install python-binance” it’s GitHub repository is GitHub - sammchardy/python-binance: Binance Exchange API python implementation for automated trading I hope this helps

Sorry, but this is not an official library, please use the suggestions from my previous comment to troubleshoot, if you can’t discover, you’ll have to debug your local code and maybe reach out to the library’s community for further explanation on its usage.