Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you fix Google OAuth API - (403) There is a per-IP or per-Referer restriction configured on your API key

I have recently moved a project over to another server. The domain name is the same, it has just been pointed to the new server. The URL is exactly the same. Since moving the project over however I get this error when the app tries to connect to 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) would be that I haven't added the new server IP into the list of allowed IP's in the devlopers console under APIs & auth->Credentials->Key for server applications.

I have added the IP. I've checked the domain has propagated by pinging it and the new IP comes up which has been entered in the console so i'm struggling to work out why it doesn't work.

Has anybody come across this before that may be able to help me solve it?

like image 461
Michael Wilson Avatar asked Mar 10 '15 13:03

Michael Wilson


People also ask

Can't connect to Google API Please check your OAuth credentials again?

"Could not connect to Google API, please check your OAuth credentials again." You can fix this by making sure "Google Workspace Admin" is set to "Unrestricted" access.

How do I fill my OAuth consent screen?

Configure OAuth consent & register your appIn the Google Cloud console, go to Menu menu > APIs & Services > OAuth consent screen. Select the user type for your app, then click Create. Complete the app registration form, then click Save and Continue.


2 Answers

Go to Project -> APIs & Auth -> Credentials -> API Key -> Create New Key -> Browser Key. It may take upto 5 minutes to reflect changes. And it worked for me.

like image 56
Ronak Rathod Avatar answered Jan 04 '23 11:01

Ronak Rathod


After you added your new server IP you need to generate a new API key from the Console. This message shows up when access in not properly configured. Look here and scroll down to "accessNotConfigured".

So, go to your developer console, Project -> APIs & Auth -> Credentials -> Public API Access -> Create New Key -> Server Key. Use this new key and you should be good to go.

like image 36
pointNclick Avatar answered Jan 04 '23 11:01

pointNclick