Ruby Google Drive API -- Unitialized Constant OOB_URI

Viewed 217

I am using the Google Drive API via the google-api-client ruby gem for a project, and I have some extracted code for authorization that looks like this:

google_setup.rb

client_id = Google::Auth::ClientId.from_file Rails.root.join('lib', 'assets', 'credentials.json').freeze
token_store = Google::Auth::Stores::FileTokenStore.new file: 'token.yaml'
authorizer = Google::Auth::UserAuthorizer.new client_id, Google::Apis::DriveV3::AUTH_DRIVE, token_store
user_id = 'default'
credentials = authorizer.get_credentials user_id
if credentials.nil?
  url = authorizer.get_authorization_url base_url: 'https://seeburg.herokuapp.com/'
  puts 'Open the following URL in the browser and enter the ' \
       "resulting code after authorization:\n" + url
  code = ENV["GOOGLE_CODE"]
  credentials = authorizer.get_and_store_credentials_from_code(
    user_id: user_id, code: code, base_url: OOB_URI
  )
end
drive_service = Google::Apis::DriveV3::DriveService.new
drive_service.client_options.application_name = 'Seeburg Google Drive Integration'
drive_service.authorization = credentials
drive_service

In the 3rd line, notice Google::Apis::DriveV3::AUTH_DRIVE. That was originally Google::Apis::DriveV3::AUTH_DRIVE_METADATA_READ_ONLY and everything was working fine. When I change it to AUTH_DRIVE (so I can download files & not just get their names), I get the error NameError (uninitialized constant GoogleSetup::OOB_URI).

I cannot find anything about this online. Please let me know if you know anything about this!

token.yaml

default: '{"client_id":"897908996328-12bdoukc29a5qvhffjpft18dkjtcgr60.apps.googleusercontent.com","access_token":"REDACTED","scope":["https://www.googleapis.com/auth/drive"],"expiration_time_millis":1602463446000}'

---UPDATE----

When I add OOB_URI = "urn:ietf:wg:oauth:2.0:oob".freeze to the top line, which I saw in the Ruby quickstart, it instructs me to open the URL, and then authorize the app, and then get the new code. I do that, I input the new code, and then it asks me to do it again in an infinite loop.

--- UPDATE 2.0 --- Changing the perm levels in token.yaml stopped the error, but didn't solve the larger problem. I still can't download the files. Even though as far as I can tell, I should have the permissions to, is_app_authorized is still false. I'm at a loss.

0 Answers
Related