Not a valid key=value pair (missing equal-sign) in Authorization header

My key is getting rejected all the time. Why is that ?

Here is my code :

import requests
import json
from web3 import Web3, HTTPProvider

# Define your relay and ERC20 token details
RELAYER_API_KEY = 'your-relayer-api-key'
RELAYER_SECRET_KEY = 'your-relayer-secret-key'
RELAYER_URL = 'https://api.defender.openzeppelin.com/relayer'
ERC20_TOKEN_ADDRESS = 'your-erc20-token-address'
MY_WALLET_ADDRESS = 'your-wallet-address'

# Define the user's private key
USER_PRIVATE_KEY = 'user-private-key'

# Initialize web3
web3 = Web3(HTTPProvider('https://rpc-mumbai.matic.today'))

# Define the ERC20 transfer function signature
TRANSFER_FUNCTION_SIGNATURE = web3.sha3(text='transfer(address,uint256)').hex()[0:10]

# Define the amount of tokens to transfer (2 tokens with 0 decimals)
TOKEN_AMOUNT = web3.toHex(2)

# Define the data to be sent in the transaction
data = TRANSFER_FUNCTION_SIGNATURE + \
       web3.toHex(web3.toBytes(hexstr=MY_WALLET_ADDRESS)).rjust(64, '0') + \
       TOKEN_AMOUNT.rjust(64, '0')

# Define the headers for the HTTP requests
headers = {
    'Accept': 'application/json',
    'Content-Type': 'application/json',
    'X-Api-Key': RELAYER_API_KEY,
    'Authorization': f'Bearer {RELAYER_SECRET_KEY}'
}

# Define the payload for the transaction
payload = {
    'to': ERC20_TOKEN_ADDRESS,
    'value': '0x0',
    'speed': 'fast',
    'gasLimit': '0x5208',  # 21000 in hexadecimal
    'data': data
}

# Send the transaction
response = requests.post(f'{RELAYER_URL}/txs', headers=headers, data=json.dumps(payload))

# Print the response
print(response.json())

Here is the message i receive :

{'message': "'<secretkey>' not a valid key=value pair (missing equal-sign) in Authorization header: 'Bearer <secretkey>'."}

My quick guess would be that you should fix this to f'Bearer={RELAYER_SECRET_KEY}'.

That was the first thing I tried. Didn't work. Were you able to replicate?

Does RELAYER_SECRET_KEY include a space or any other unsafe character?
If yes, then it should probably be double quoted.

I would also add that I'm not familiar with 'speed': 'fast', although it doesn't seem to be related to the error that you're getting, but you might wanna double-check that pair.