How do you fix the Google OAuth API - (403). Your API has a restriction on each IP address or each referrer

I recently moved the project to another server. The domain name is the same, he just pointed to the new server. The url is exactly the same. Since the project is moving, I get this error when the application tries to connect to the googles OAuth api.

{ "name": "Error calling GET https:\/\/www.googleapis.com\/analytics\/v3\/management\/accounts\/~all\/webproperties\/~all\/profiles?key=AIzaSyBKUP8JriiOnFnbJm_QYt_bHTMuHf-ilAI: (403) There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referer should be allowed.", "url": "\/analytics\/statistics.json" } 

The obvious reason (based on the error message) is that I did not add the new server IP address to the list of allowed IP addresses in the devlopers console under the API and auth-> Credentials-> Key for server applications.

I have added IP. I checked that the domain had spread by checking it, and a new IP address appeared, which was entered into the console, so I'm struggling to understand why it does not work.

Has anyone come across this before than can help me solve it?

+5
source share
4 answers

I had this problem for a while, but finally it was solved:

I noticed that when I tried to wget http://bot.whatismyipaddress.com/ from my server, it actually returned the IPv6 address when I entered the IPv4 address of my server on the API key configuration page. When I add the IPv6 address, my requests are finally accepted.

0
source

Go to Project -> API and Auth -> Credentials -> API Key -> Create New Key -> Browser Key. It may take up to 5 minutes to reflect the change. And it worked for me.

+5
source

After you have added a new server IP address, you need to create a new API key from the console. This message appears when access is configured incorrectly. Take a look here and scroll down to "accessNotConfigured".

So go to the developer console, Project → API and Auth → Credentials → Public API Access → Create New Key → Server Key. Use this new key and you should be fine.

+3
source

Go to Project -> API and Auth -> Credentials -> Public access to the API -> Create a new key -> Server key -> Accept requests from these server IP addresses (optional), then first delete all the IP address and update it, then try. And, later, you can add a specific IP address, which worked for me strangely.

+1
source

Source: https://habr.com/ru/post/1215056/


All Articles