0

Code-

HEADER= {
    'Authorization': f'Token {TOKEN}'
}

resp= requests.request(
    "GET",
    url,
    headers=HEADER
)

Error message-

{'detail': 'Authentication credentials were not provided.'}

resp.request.headers output

{'User-Agent': 'python-requests/2.28.1', 'Accept-Encoding': 'gzip, deflate', 'Accept': 'application/json', 'Connection': 'keep-alive'}

I have tried passing HEADER dict directly in request function (with/without fstring)
directly used .get
Basically tried everything mentioned here Python requests library how to pass Authorization header with single token

nothing worked...any idea what might be wrong
TOKEN is correct

  • 1
    Can you provide elements so we can reproduce your problem and/or the documentation of the API you want to interact with ? – Robin Nicole Nov 28 '22 at 16:29
  • sorry for late response, it was an interview assignment...I reported the issue but issue wasn't resolved. Anyway thanks you guys –  Apr 16 '23 at 20:58

1 Answers1

0

'Authentication credentials were not provided.' should be 401, and, 403 means you don't have the permission, maybe you should talk to the api provider.