Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Books API server not accepting calls from Heroku server

I'm developing an application in JAX-RS on a Heroku server but I've run into issues making calls to the Google Books API from the server. I've been using the Java libraries provided by Google to make these calls and on some occasions it works but for the most part it returns this error

403 Forbidden { "code" : 403, "errors" : [ { "domain" : "global", "message" : "Cannot determine user location for geographically restricted operation.", "reason" : "unknownLocation" } ], "message" : "Cannot determine user location for geographically restricted operation." }

I suspect that this issue is related to the dynamically generated IP address system Heroku uses for routing since the Google server is having issues detecting the origin of the API calls. How would I approach working around this? Is there any way for Heroku to use static IP addresses or could I use a proxy to act as the sole access point for the API?

like image 984
Ryan Sasson Avatar asked Oct 18 '25 20:10

Ryan Sasson


1 Answers

Just realized that this can be resolved with adding a country code to the Google Books query (&country=US) or adding a x-forwarded-for header from the original HTTP request.

http://productforums.google.com/forum/#!topic/books-api/7FQ-622q-jI

like image 67
Ryan Sasson Avatar answered Oct 22 '25 05:10

Ryan Sasson