0

I am trying to set up ezsheets for the use with Google Sheets. I followed the instructions from here https://ezsheets.readthedocs.io/en/latest/ and here https://automatetheboringstuff.com/2e/chapter14/

The set up process works quite differently on my computer: Somehow I could download the credentials-sheets.json. I need to download the token-sheets.pickle and token-drive.pickle files. When I run import ezsheets, no browser window is opended as described in the set up instructions. Nothing happens.

Is there another way to download both files?

aurumpurum
  • 932
  • 3
  • 11
  • 27

1 Answers1

0

I followed the steps you referenced and managed to generate the files, but I also encountered the same issue before figuring out the cause. The problem is that there are a few possible causes and the script silently fails without telling you exactly what happened.

Here are a few suggestions:

  • First off you need to configure your OAuth Consent Screen. You won't be able to create the credentials without it.

  • Make sure that you have the right credentials file. To generate it you have to go to the Credentials page in the Cloud Console. The docs say that you need an OAuth Client ID. Make sure that you have chosen the correct app at the top.

Adding credentials

Then you will be prompted to choose an application type. According to the docs you shared the type should be "Other", but this is no longer available so "Desktop app" is the best equivalent if you're just running a local script.

Choose the app type

After that you can just choose a name and create the credentials. You will be prompted to download the file afterwards.

  • Check that the credentials-sheets.json file has that exact name.
  • Make sure that the credentials-sheets.json file is located in the same directory where you're running your python script file or console commands.
  • Check that you've enabled both the Sheets and Drive API in your GCP Project.
  • Python will try to setup a temporary server on http://localhost:8080/ to retrieve the pickle files. If another application is using port 8080 then it will also fail. In my case a previously failed Python script was hanging on to that port.

To find and close the processes using port 8080 you can refer to this answer for Linux/Mac or this other answer for Windows. Just make sure that the process is not something you're currently using.

I just used the single import ezsheets command to get the files so after getting the token-sheets.pickle I had to run it again to get the token-drive.pickle, but after that the library should detect that you already have the files.

Daniel
  • 3,157
  • 2
  • 7
  • 15
  • I checked your first three bullet points. Regarding port 8080 I first checked, which connections are active with the command: netstat -ano. I couldn't find any active connection to port 8080. So there is no process to kill. – aurumpurum Mar 04 '22 at 07:39
  • I got my credentials-sheets.json file with this method: https://www.youtube.com/watch?v=rWcLDax-VmM. This may be another potential cause of the problem. After downloading it, I renamed the file an put it in the folder, where I want to run my python scripts. – aurumpurum Mar 04 '22 at 07:46
  • That's another issue for sure. The video shows how to create a service account key, but ezsheets needs a OAuth client ID, which is different. I have amended my answer to add that as well. – Daniel Mar 04 '22 at 16:44