How to Access google sheets offline with python - python

Actually I'm doing a attendance management system which gets the users Id, in time and uploads it to google sheet. Now the catch is inorder to write in google sheet we need internet, I know I can use Microsoft excel instead, But for certain reason I need to use Google sheets (because it includes a google script). Now I need to know whether I can write to google sheets without the internet or not!!

I understand that you want offline access to Sheets using Python. If I understood the situation correctly, you only need to give an eye to this guide about OAuth 2.0 for Desktop Apps, especially the part about calling Google APIs. Please, ask me any doubts about this approach.

Related

oauth2 authentication failing when called from google cloud function

I am trying to create a google cloud function that is called when a user clicks a button in google sheets. This function goes through the data and updates another sheet. I have been using pygsheets to do this but I would like to use google cloud functions so that anyone can update the sheet without emailing me to open a terminal and run the script.
My initial error message says that when i run pygsheets.authorize() that this method is trying to write in a read only file system. I have tried to make my own custom credentials but have gotten nowhere with them. I have linked the conversation I had with the maintainer of the pygsheet project.
I am self taught and thus would happily take any advice on how to resolve this issue. I would like to keep using pygsheets if possible as I have not seen any python google sheets tools on par with it. Please help this issue has stumped me for a couple of weeks.

upload files to google drive without logging in

So with the google sheets api, I can use a credentials json file to edit a google sheet. I don't have to login again and again. Is it possible to do this same thing with the google drive api? I am making a Python webapp, and it is very inefficient to need to log into a google account every time I want to upload a file. I plan on only uploading files to one drive, and not multiple accounts. I have looked on stack overflow a couple times, and can only find documentation on how to login with a user account and this requires I login every time.
Best wishes,
Jake
You can do the same thing as in Sheets, follow the official Python Quickstart from the docs for instructions on how to do it.

Saving Spreadsheet to Folder in Google Sheets API (Python)

I am working with the Google Sheets API in Python but am having trouble finding out how to save a newly created Spreadsheet to a specific folder. As of now all it does is populate my drive without the ability to indicate an end location. Any idea how to do this in Python?
I have found help with other languages but the python documentation is much different. Any insight would be great...

Retrieve the content of access-permitted private google sheets from API?

I have an access to the not-mine private spreadsheet on the Google Sheet. When I access to that spreadsheet from browser, everything is fine. But, when I try to retrieve the content of that spreadsheet through Google Sheets API using Python, I am getting 403 error - "The caller does not have permission".
The problem is I can not ask the owner to give me one more permission for my API.
Can I retrieve the content of that spreadsheet somehow? Maybe using some tools?
You prolly can access it because you got the link from someone. But to access it using the API will require you to be added in the permissions. Worth checking would be this Google Drive SDK: Sharing Files tutorial video and the Permissions docs.

Persistent SpreadsheetNotFound errors on specific Google Sheets spreadsheets in gspread for Python

I am using gspread to collect data from several hundred Google Sheets spreadsheets. I parse the files stored by Google Drive in a local directory and obtain the URLs for all the spreadsheets within a specified folder. Then I use a python wrapper to go through the URLs and a shell script wrapper to jump start the python wrapper when the connection glitches out.
One of the causes for the glitches is the SpreadsheetNotFound error. I did a quick check about halfway through and found that 21/139 (~15%) of my spreadsheets always get this error (I have it skip the spreadsheet if it's not found five times). I have gone in with iPython and manually tested these with open_by_url, open_by_key, and open (with the title), but they all return the same SpreadsheetNotFound error. The most frustrating part is being able to copy the URL directly from my error message, pasting it in the browser, and the browser going straight to the spreadsheet without a problem. The second most frustrating part is that it works beautifully for ~85% of the spreadsheets, but 85% is not exactly going to cut it.
I'm not even sure this is solvable. I'm just curious if anyone else out there has had this problem with gspread.
Thanks for any feedback.
Edit 1: Hm, the failing spreadsheets were all created prior to 2/2/15. The older sheets have been updated to the newest version of Drive - that may have had an effect on the API.
From the Gspread docs:
ClientLogin is deprecated:
https://developers.google.com/identity/protocols/AuthForInstalledApps?csw=1
Authorization with email and password will stop working on April 20, 2015.
Please use oAuth2 authorization instead:
http://gspread.readthedocs.org/en/latest/oauth2.html
So I assume you're using oAuth2. Which means you need to add the email address in that json cert file to the spreadsheet.
Using OAuth2 for Authorization
See point #7:
Go to Google Sheets and share your spreadsheet with an email you have
in your json_key['client_email']. Otherwise you’ll get a
SpreadsheetNotFound exception when trying to open it.

Categories