Python request headers. error authenticating with JSON WEB TOKEN

Question:

I’m learning python by building a simple trading bot. I receive this error while trying to authenticate using a JWT

{
  "error": {
    "status": 403,
    "message": "Authentication credentials were not provided."
  }
}

following the example here https://docs.ledgerx.com/reference/tradedcontracts

import requests

url = "https://api.ledgerx.com/trading/contracts/traded"

headers = {
    "Accept": "application/json",
    "Authorization": "MY_API_KEY"
}

response = requests.get(url, headers=headers)

print(response.text)

for now im inserting the string literal later i will store this value in an .env

thanks for taking the time to read

Asked By: cmg

||

Answers:

Can you try this please

import requests

url = "https://api.ledgerx.com/trading/contracts/traded"

headers = {
    "Accept": "application/json",
    "Authorization": "JWT MY_API_KEY"
}

response = requests.get(url, headers=headers)

print(response.text)
Answered By: Himanshuman