I was recently working on a project using https://console.cloud.google.com/apis/, but when I tried to restrict the API key to my repl.it project website (search.myreplitusername.repl.co
), it broke the search feature at my repl.it page that depends on the Google API.
After I restricted the API key to search.myreplitusername.repl.co
or *.myreplitusername.repl.co
I got this in the console:
PHP Warning: file_get_contents(https://www.googleapis.com/customsearch/v1?key=MY_API_KEY&cx=MY_CX&q=search+query): failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden
Does anyone know why this is happening or how to fix this?