I answered something like this in several other posts that I found were like this ... so its relevant, for ruby, using google-api-client (for any of google-apis), there are several inputs and outputs with authentication when using the api key, not OAuth ...
I set out this process (using the server side of the api server) in a space of code .
You must explicitly specify the authorzation nil parameter when building the client, otherwise the pearl will try to use OAuth for authentication, so when you call from the server using only the api key, you will always have 401 Unauthorized.
abode code - google-api-client for ruby
source share