1
votes

I'm trying to use the "Google Identity Toolkit" with the "tutorial" android demo app, but now I get this error:

{
  "error": {
    "errors": [
      {
        "domain": "usageLimits",
        "reason": "ipRefererBlocked",
        "message": "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.",
        "extendedHelp": "https://console.developers.google.com"
      }
    ],
    "code": 403,
    "message": "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."
  }
}

Any Idea? In the Google console I need allow some thing? Where?

OAuth 2.0 client IDs:

Android,
Web application

And on Identity Toolkit API console, it allow I select "Web application" client ID in Google provider.

And I have set up this in my "tutorial" app

3
I'm voting to close this question as off-topic because it's related to an API configuration and not a development question. - Cory Charlton

3 Answers

1
votes

This error is usually caused when you are trying to run the code on a URL you didn't add to the referrer URLs in the console.

To fix this go to the Google Developer Console, then under API Manager click credentials and find your browser key. On this page you can add any URLs that will be using that key. Remember it treats www. differently, so to cover all possible pages you could do this: .domain.com/ domain.com/*

0
votes

I figured out today that there is a bug when you create a new Android API key. You will have probably noticed that there was also a Browser API key that was generated when you created the Android API key. My Browser API key had no name, and was therefore not configurable. However, I performed a bit of URL manipulation magic to be able to access and edit my Browser API key. Here's what I did:

1) Click on the name of the Android API key

2) Edit the URL right before the ? such that the number before the ? matches the (0-based) index of the position of your Browser API key. That is, if your browser api key appears second in your list of two API keys, then your Android API key would have been first, at position 0. Therefore the URL would read something like this:

.../key/0?...

So now you want to change it to look like this:

.../key/1?...

3) From here you should be able to change your allowed referrers to

http://yourdomain.com/*

Then, so long as you have your keys set up properly everything should work as expected! Also, note that after you do this once you will then have a name for your browser key, and it will be easily editable in the future!

Best of luck!

0
votes

You will need to...

  1. Create an Android API Key
  2. Set the package name and SHA-1 of your signing key file(see gitkit guide on how to do that)
  3. Use that API Key for the identitytoolkit.api_key value