0

I had connected to google sheets in python using the json key file which was available on my computer. Now the key file is available online on slack/google drive. How do i use it so that everyone in my org is able to make changes to the python code linked to a particular spreadsheet?

This was the code before:

credentials = ServiceAccountCredentials.from_json_keyfile_name(
r"C:\Users\nilad\OneDrive\Desktop\creds.json", scope)

This worked fine.

The code now:

credentials = ServiceAccountCredentials.from_json_keyfile_name(
"https://layerfive.slack.com/files/UKVDY5RTN/F02CRDN636C/layerfiveintegrationmonitoring-c47eacd6d461.json", scope)

This throws an error on the path towards the json file.

  • You need to download the file first and then put the path of the downloaded file in your code. – Philippe Oger Aug 24 '21 at 11:01
  • so there is no alternative way to directly import it from a google drive link? i mean how do other people in the org make changes to this code? – Niladri Santra Aug 24 '21 at 11:06
  • I meant, your code must download the json file first automatically, then create the credentials object with the just downloaded file. This answer from another post should help you get the code working to download the file first: https://stackoverflow.com/a/18043472/4076481 – Philippe Oger Aug 24 '21 at 12:28
  • No there isn't, it needs to be downloaded. What do you mean by `how do other people in the org make changes to this code`? – Rafa Guillermo Aug 24 '21 at 12:28
  • i mean if someone else makes changes to this code it would not execute because the path that i have defined doesn't exist on their device. – Niladri Santra Aug 24 '21 at 14:04

1 Answers1

0

The credentials file needs to be downloaded to the local disc. You can't link an online version of the file as this is not supported.

If you wish other people to edit the code and test it, then they will also need a copy of the credentials file.

Rafa Guillermo
  • 14,474
  • 3
  • 18
  • 54