bitfocus/companion-module-google-sheets

OAuth Code - What needs to be in the field?

Fred-DTV opened this issue · 20 comments

Hey hey,

I wanted to try the module for the first time, but I can't get it to connect.

It's probably a setup problem, as I don't really understad what needs to go into the "OAuth" field

The link i'm getting when following the authentication process is the following:

http://localhost:8001/?code=4/0AdQt8qgGrN_98V4sm_IQdUhenOp06p6jkh1Vq-NDc3psmOm0EegA_ZBlsMU-vHPPOEnI_A&scope=https://www.googleapis.com/auth/spreadsheets

Which part needs to be added into the settings?

Thanks in advance,
Fred

Oh and the redirect page after the authentification says "unable to connect"

Should it show something different?

The Companion module doesn't currently host a webpage, which is why it 404's, and this'll be properly handled in an upcoming patch.

For the time being, you need to copy the code portion of the URL and paste that into the OAuth Code field. So for the URL you linked you would paste 4/0AdQt8qgGrN_98V4sm_IQdUhenOp06p6jkh1Vq-NDc3psmOm0EegA_ZBlsMU-vHPPOEnI_A into the OAuth Code in the module config.

Hi Jeff, my Google Sheets module status says the green "OK" that it is connected, but the "Spreadsheets" dropdown in the button Action doesn't populate. I've double checked the Spreadsheet ID is correct... anything else I should try? I do see the Read request counter ticking up, but not the write, exceed, or backoff.
Screen Shot 2022-07-26 at 7 56 48 PM

same for me now. Connection is ok, but no spreadsheets to choose from

I'm having the same issue, used the Spreadsheet ID from the url between the /d/ and /edit. Tried with " " and without, and tried multiples. Nothing will populate in the select spreadsheet dropdown. Anything I'm missing?

I'm still looking in to why the Spreadsheet may not be updating your actions to allow it to be selected. I may have to add some additional logging to the next beta version.

There's now been an update to add more logging, you should be able to see debug messages in the log if there are any errors from the Google API.

Here's what I get on the debug (status still shows OK):

2022-08-17T17:37:00.537Z instance(Google Sheets) debug Updating variables for 0 sheets, from 0 Spreadsheets  
2022-08-17T17:37:00.894Z instance(Google Sheets) debug Token Refreshed - {access_token":"REDACTED" expires_in:3599
2022-08-17T17:37:00.898Z instance(X_opQKUZZ) debug instance configuration updated  
2022-08-17T17:37:01.271Z instance(Google Sheets) debug getSheet err: Response code 403 (Forbidden)  
2022-08-17T17:37:01.272Z instance(Google Sheets) debug Updating variables for 0 sheets, from 0 Spreadsheets  
2022-08-17T17:37:02.403Z instance(Google Sheets) debug Updating variables for 0 sheets, from 0 Spreadsheets  
2022-08-17T17:37:03.904Z instance(Google Sheets) debug Updating variables for 0 sheets, from 0 Spreadsheets  
2022-08-17T17:37:05.409Z instance(Google Sheets) debug Updating variables for 0 sheets, from 0 Spreadsheets  
2022-08-17T17:37:07.180Z instance(Google Sheets) debug getSheet err: Response code 403 (Forbidden)  
2022-08-17T17:37:07.181Z instance(Google Sheets) debug Updating variables for 0 sheets, from 0 Spreadsheets  
2022-08-17T17:37:08.415Z instance(Google Sheets) debug Updating variables for 0 sheets, from 0 Spreadsheets  
2022-08-17T17:37:09.916Z instance(Google Sheets) debug Updating variables for 0 sheets, from 0 Spreadsheets  
2022-08-17T17:37:11.420Z instance(Google Sheets) debug Updating variables for 0 sheets, from 0 Spreadsheets  

Similarly, I get:

22.08.17 17:26:28 instance(sheet): getSheet err: Response code 403 (Forbidden)
22.08.17 17:26:27 instance(sheet): Updating variables for 0 sheets, from 0 Spreadsheets
22.08.17 17:26:25 instance(sheet): Updating variables for 0 sheets, from 0 Spreadsheets
22.08.17 17:26:24 instance(sheet): Updating variables for 0 sheets, from 0 Spreadsheets
22.08.17 17:26:23 instance(sheet): Updating variables for 0 sheets, from 0 Spreadsheets
22.08.17 17:26:23 instance(sheet): getSheet err: Response code 403 (Forbidden)
22.08.17 17:26:21 instance(sheet): Updating variables for 0 sheets, from 0 Spreadsheets
22.08.17 17:26:20 instance(sheet): Updating variables for 0 sheets, from 0 Spreadsheets
22.08.17 17:26:19 instance(sheet): Updating variables for 0 sheets, from 0 Spreadsheets
22.08.17 17:26:18 instance(sheet): Updating variables for 0 sheets, from 0 Spreadsheets
22.08.17 17:26:18 instance(sheet): getSheet err: Response code 403 (Forbidden)
22.08.17 17:26:16 instance(sheet): Updating variables for 0 sheets, from 0 Spreadsheets
22.08.17 17:26:15 instance(sheet): Updating variables for 0 sheets, from 0 Spreadsheets
22.08.17 17:26:14 instance(sheet): Updating variables for 0 sheets, from 0 Spreadsheets
22.08.17 17:26:13 instance(sheet): Updating variables for 0 sheets, from 0 Spreadsheets
22.08.17 17:26:13 instance(sheet): getSheet err: Response code 403 (Forbidden)
22.08.17 17:26:11 instance(sheet): Updating variables for 0 sheets, from 0 Spreadsheets
22.08.17 17:26:10 instance(sheet): Updating variables for 0 sheets, from 0 Spreadsheets
22.08.17 17:26:08 instance(sheet): Updating variables for 0 sheets, from 0 Spreadsheets
22.08.17 17:26:07 instance(sheet): Updating variables for 0 sheets, from 0 Spreadsheets
22.08.17 17:26:07 instance(sheet): getSheet err: Response code 403 (Forbidden)
22.08.17 17:26:06 instance(sheet): Updating variables for 0 sheets, from 0 Spreadsheets
22.08.17 17:26:04 instance(sheet): Updating variables for 0 sheets, from 0 Spreadsheets
22.08.17 17:26:03 instance(sheet): Updating variables for 0 sheets, from 0 Spreadsheets
22.08.17 17:26:02 instance(sheet): Updating variables for 0 sheets, from 0 Spreadsheets
22.08.17 17:26:02 instance(sheet): getSheet err: Response code 403 (Forbidden)
22.08.17 17:26:01 instance(sheet): Updating variables for 0 sheets, from 0 Spreadsheets
22.08.17 17:25:59 instance(sheet): Updating variables for 0 sheets, from 0 Spreadsheets
22.08.17 17:25:58 instance(sheet): Updating variables for 0 sheets, from 0 Spreadsheets
22.08.17 17:25:58 instance(C0hsJ6lVI): instance configuration updated
22.08.17 17:25:58 instance(sheet): Token Refreshed - {"access_token”:”REDACTED”,”expires_in":3599,"scope":"https://www.googleapis.com/auth/spreadsheets","token_type":"Bearer"}
22.08.17 17:25:58 instance(C0hsJ6lVI): instance configuration updated
22.08.17 17:25:58 instance(sheet): Updating variables for 0 sheets, from 0 Spreadsheets
22.08.17 17:25:57 instance(sheet): Updating variables for 0 sheets, from 0 Spreadsheets
22.08.17 17:25:57 instance(sheet): getSheet err: Response code 403 (Forbidden)
22.08.17 17:25:56 instance(sheet): Updating variables for 0 sheets, from 0 Spreadsheets
22.08.17 17:25:54 instance(sheet): Updating variables for 0 sheets, from 0 Spreadsheets
22.08.17 17:25:53 instance(sheet): Updating variables for 0 sheets, from 0 Spreadsheets
22.08.17 17:25:52 instance(sheet): Updating variables for 0 sheets, from 0 Spreadsheets
22.08.17 17:25:52 instance(sheet): getSheet err: Response code 403 (Forbidden)
22.08.17 17:25:52 instance(C0hsJ6lVI): instance configuration updated

Can you try with different sheets, eg ones made by someone else, one made by yourselves, and one that is fully public with no restrictions on sharing. I'm trying to figure out why it's 403'ing when myself and my initial testers can access any sheet that our Google account would have access to.

Yeah i was having the same issues as @Terranesaurus and @davidjoshuaford but i found the issue i was having. In the connection instance spread sheet ID section, i removed the "/edit#gid=0" part of the ID. I assume that wasnt meant to be a part of it. Whoops.

Very keen on the module btw, thank you so much for putting your time into developing it!

@J-Boer so it is working for you now? I have the sheet ID entered correctly, and also opened up the spreadsheet sharing permissions to general (which is not ideal moving forward if there's client data in there), but still don't get any Spreadsheet field drop-down.

I made a new sheet with editor permissions as "Anyone with the link" and still was getting the 403. My account is a Gsuite account, could that have anything to do with it? I set the OAuth up with the same account that the Sheets live under. I've also tried this on a sheet that lives on another account that I have edit permissions on, still the same behavior.

@davidjoshuaford It is working, yes. I also have my sheet to be restricted to only myself, so you shouldn't need to make it publicly editable. When you place the Client ID and Client Secret into the connection feilds, I click save which opens a page that never really loads - I was stumped on that for a while. I grab the code section from the URL on the page and paste that into the OAuth Code section in Companion. Then i get the right spreadsheet ID (thats where i messed up first).

Also in the Redirect URI i did change it to be "http://localhost:8080/". I did that both in Google Cloud API, and in Companion.

Make sure to check the client ID and secret copied over correctly. My google cloud isnt set up right yet and i think those can update over time.

@J-Boer I believe I've followed all those steps correctly.

I'm using the redirect URI that was in the module instructions: "http://localhost:8001". I've also tried changing it to "http://localhost:8080/" but it still doesn't come through (unless it just needs longer to propagate).

I'm using my Google Workspace account... Are you using a gmail address or Workspace version?

@davidjoshuaford I am using a personal gmail address. Weird. Maybe try and make a new credential on google cloud and use a new instance of the module? Along with trying with a Personal gmail?

Hope that works out for you.

@davidjoshuaford Did you make sure to enable Google Sheets API in the libary section in Google Cloud?

@J-Boer the Sheets API was the step I was missing. It appears to be working now. Thank you!
@thedist I'd recommend adding that step to the connection instructions.

@Terranesaurus yes - same for me! Turned that on and now the dropdown is populated. Look forward to diving into this module.

I'll update the instructions to make that clearer, that was my fault.

Additionally the page that you get redirected to is meant to 404 as at the time I released the beta there was no way to get Companion to display a page that would essentially say "Hey, you've successfully granted permissions needed, you can close this page now", which is why it would require you to manually copy the code portion from the URL regardless of what you URL:Port you redirect to. I've since added the ability to the Companion Core to allow modules to display a page and automate that step to some degree so this will become much more user friendly before the module gets out of beta.