Error 401 while getting a market quote

I’m new to using this API and I’m not sure what’s causing this error. I have a separate code which authenticates the API key and it’s working fine, returning 200. But for some reason, this code does not work and returns 401:

url = ''
headers = {
    'Authorization': f'Bearer {UPSTOX_API_KEY}'

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

The API access type is API Trading.

A 401 error indicates that the token is invalid or has expired. The access_token obtained through the API is valid until 3:30 AM the following day, regardless of when it was generated. For example, if you generate a token at 8 PM on Tuesday, it will expire at 3:30 AM on Wednesday. Similarly, a token created at 2:30 AM on Wednesday will still expire at 3:30 AM on the same day. Users should plan their activities accordingly to accommodate the token’s expiration schedule.

To get started quickly, refer to the sample code here: Upstox API Documentation Example Code.