2
votes

I'm trying to create a web application with rails which can access to a google drive spreadsheet and:

  1. List the content [read only]
  2. Can add/modify values

Is there a way of doing that without using oauth? I currently have a solution with oauth, but I would like to have at least the read only access without oauth and if possible also to modify them.

EDIT: I'm currently using google drive ruby gem https://github.com/gimite/google-drive-ruby

Thanks in advance

2
If you just want to access sheet(same sheet everytime) without accessing drive then the sheet which is shared as "Anyone with link can edit/comment" can be accessed without oauth. But if you want to go with accessing drive and then sheets inside the drive then you have to use oauth as all the google api's needs authentication with oauth.SGC

2 Answers

0
votes

As a read only you can use a HTML solution as I answered here:

Partial CellFeed load

0
votes

The solution was finally quite simple. The problem was that I didn't see on the doc of the gem I was using (Google Drive Ruby) that there is a method called login with user and password. Finally the solution would be something like:

class StockController < ApplicationController
  before_action :login

  def index 
    respond_to do |format|
      format.json{ render json: document.rows}
    end
  end

  def login
    @session = GoogleDrive.login(ENV["GDRIVE_USERNAME"], ENV["GDRIVE_PASSWORD"])
  end

  def document
    @session.spreadsheet_by_key("key_of_the_spreadsheet").worksheets[0]
  end
end