Voronchuk / elixir_google_spreadsheets

Elixir library to read and write data of Google Spreadsheets.
MIT License
79 stars 37 forks source link

Can I use the library to access Google Spreadsheets of users who sign in with Google OAuth? #45

Open tadasajon opened 3 years ago

tadasajon commented 3 years ago

I have a situation in which users sign in to my app using their Google accounts. I then need to be able to read their Google Sheets. It is not clear to me whether this library would permit this, or whether this library only gives access to the Google Sheets of one account -- i.e., my Google account.

Thanks.

Voronchuk commented 3 years ago

Hi, the intended usage is with Google Service account. The main difference is that some registry logic is used to request and cache an authorization token. In your case, you should already have the valid token with the required permissions, which you should have been able to pass directly.

So if you don't have any other elixir library to achieve this goal, you can fork and modify functions like this: https://github.com/Voronchuk/elixir_google_spreadsheets/blob/master/lib/elixir_google_spreadsheets/spreadsheet.ex#L560

Replace %{"Authorization" => "Bearer #{GSS.Registry.token()}"} with %{"Authorization" => "Bearer #{Keyword.fetch!(options, :auth_token)}"}

Or modify GSS.Registry.token() to return token scoped to specific user.