Calendar API only working with localhost requests, "invalid" with IP addresses
I need to insert an event using the Calendar API. I used the example provided here under: /samples/calendar/calendar.rb within a RoR v4.2.2 app, and it does work when running the app as localhost, but it fails when the app is accessed with an IP address. I have read all the official docs in https://developers.google.com/api-client-library/ruby already. The env variable GOOGLE_APPLICATION_CREDENTIALS points to a (JSON) "Service Account" Key.
How to replicate: "rails s" <-- WORKS "rails s --bind=0.0.0.0" <-- FAILS with: "Google::Apis::ClientError (invalid)"
Is this a bug? or are we forced to host the app in the Google Cloud? or Am I missing something?
Any ideas please?
Unless rails is doing something bizarre, binding the rails server address shouldn't affect the client. Can you provide a more detailed error/stack trace?
FWIW, just tried with a small test rails app and unable to reproduce. Not sure what's wrong with your config, but again, it shouldn't matter what address the server is listening on.
This repository has an example: https://github.com/endlos/G_Calendar_V3_with_api_ruby_client_v0.9.git
I include a service account private key also, so you can directly try:
$ rails s <-- Open URL: "localhost:3000" OK $ rails s --bind=0.0.0.0 <-- Open URL: "192.168.1.X:3000" FAILS with "Google::Apis::ClientError (invalid):"
Thanks
{ "error": { "errors": [ { "domain": "global", "reason": "invalid", "message": "Invalid attendee email." } ], "code": 400, "message": "Invalid attendee email." } }
It's your code...
attendees: ARGV.map { |email| Calendar::EventAttendee.new(email: email) },
Thank you @sqrrrl !!!