Search code examples
ruby-on-railsrubygoogle-url-shortener

Google URL Shortener returns error, {"domain"=>"usageLimits", > "reason"=>"ipRefererBlocked


I'd like to use google url shortener on ruby. I've been using googl. At the google developer console, I've got an api key. I've set the ip address "127.0.0.1".

Then, I wrote as following, however it returned an error. Could you tell me how to solve the problem?

Googl.shorten('url',"127.0.0.1",my_api_key)

Googl::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."}}): app/controllers/products_controller.rb:102:in `create'


Solution

  • At a google developer console, if I made api key not specifying ip address, it didn't return error. But I'm still not sure why it returns error when it is specified ip address.