google-api-ruby-client icon indicating copy to clipboard operation
google-api-ruby-client copied to clipboard

Calendar API only working with localhost requests, "invalid" with IP addresses

Open endlos opened this issue 10 years ago • 5 comments

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?

endlos avatar Dec 18 '15 23:12 endlos

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?

sqrrrl avatar Dec 18 '15 23:12 sqrrrl

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.

sqrrrl avatar Dec 18 '15 23:12 sqrrrl

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

endlos avatar Dec 19 '15 00:12 endlos

{ "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) },

sqrrrl avatar Dec 20 '15 21:12 sqrrrl

Thank you @sqrrrl !!!

endlos avatar Dec 21 '15 01:12 endlos