简体   繁体   中英

Python request headers. error authenticating with JSON WEB TOKEN

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

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM