This has certainly had me baffled for a couple hours. I've bootstrapped my application as detailed by Baugues to the point that authentication via OAuth2 works and I'm just testing things out in the session#create
(callback) action. Here's some code:
class SessionsController < ApplicationController
def create
@auth = request.env["omniauth.auth"]
@token = @auth["credentials"]["token"]
client = Google::APIClient.new
client.authorization.access_token = @token
service = client.discovered_api('drive', 'v1')
file_content = Google::APIClient::UploadIO.new("foo", "text/plain")
# @result = client.execute(
# :api_method => service.files.get,
# :parameters => { 'id' => 1 },
# :headers => {'Content-Type' => 'application/json'})
end
end
Upon authenticating, the above logic is executed in the callback
method - which for the purpose of this crude test renders out create.html.erb
. I've commented out the @result
instance variable that's just echoed out into the view.
However, Google::APIClient::UploadIO.new("foo", "text/plain")
triggers uninitialized constant Google::APIClient::UploadIO
when it clearly should not. I've dug through the source of this gem and the UploadIO
class is required
in media.rb
of the gem.
Advice and assistance appreciated!