There are several threads on this with tagged solutions. Please use the search feature
This one may be helpful"
I also recommend retrieving your access token via Postman and seeing if it allows you to query the API endpoint. If successful, it can help isolate the error in your code.: Postman