Reading and writing a public google sheet with python - python

I have a public google sheet that has a bunch of license keys. I am trying to automate the read and write process from said sheet. eg. take code, run it, mark it as used.
After reading https://medium.com/analytics-vidhya/how-to-read-and-write-data-to-google-spreadsheet-using-python-ebf54d51a72c
as well as the Google's tutorial https://developers.google.com/workspace/guides/create-project
Both of those instructed me to create a google cloud platform account. Since the sheet is public, has anyone managed to read/write without it?

To make requests to a Google Workspace API with a Python command-line application, you need to complete a couple of steps in the Google Cloud Platform Console. In this case if you're using the Google Sheets API to access a Google Sheet even if is public, you need the following prerequisites which asks you to have a Google Cloud Platform project with the API enabled and create credentials for your application in the GCP console.

Related

Can python code be embeded into the google app script (Gmail add-on)?

I have python code that uses Gmail API for fetching unread emails and adding labels according to some rules.
The code runs on my computer and I wish to create a Gmail add-on for this labeling, the add-on should include a new button in the Gmail interface.
The problem is that Google add-on uses google app script.
I want to ask if there is a possibility to embed my python code into the google app script?
Thanks :)
You might use Python with Google Apps Script API to programmatically create and modify a Google Apps Script project, but the Google Apps Script uses V8 as it's runtime, and it requires JavaScript.
You might use Google Cloud Run (see https://cloud.google.com/run/docs/quickstarts/build-and-deploy/deploy-python-service) or another hosting infrastructure to use Python to use the Card Service to build the add-on user interface and use the Gmail API.
I think that it might be possible to use Google Colaboratory as the hosting infrastructure but I have no idea how convenient it will be compared to use Google Cloud Run.

How to authenticate a google vision API on cloud inside a python script?

I am trying to build a python script and deploy it as an HTTP function/Serverless cloud function on Pivotal cloud foundry or GKE, but I have gone through several articles and most of them mention using an SA and download Json key, setup env variable to JSON key location and run the script.
But how can I provide local downloaded JSON key file when I deploy it on cloud?
I have gone through below links but I couldn't understand as I am new to GCP, can anyone provide me an elaborated anws on how can I achieve this?
Google Cloud Vision API - Python
Google cloud vision api- OCR
https://cloud.google.com/vision/docs/quickstart-client-libraries#client-libraries-usage-python
According to docs, during function execution, Cloud Functions uses the service account PROJECT_ID#appspot.gserviceaccount.com as its identity. For instance, when making requests to Google Cloud Platform services using the Google Cloud Client Libraries, Cloud Functions can automatically obtain and use tokens to authorize the services this identity has permissions to use.
By default, the runtime service account has the Editor role, which lets it access many GCP services. In your case, you will need to enable the Vision API and grant the default service account with necessary permissions. Check out the Function Identity Docs for more details.
Instead of a SA json file, you could use an api key if that's easier for you. However, if you use an api key, you will only be able to send image bytes or specify a public image.

Using My Self Google Drive Api Without Oauth

I am using Google Drive Api for my Python/Flask App. This app is analyzing the picture and hiding the pictures it will analyze on google drive. The pictures already exist on my own google account.
I am using Oauth2 to access these images. But since I already have my own drive account, Oauth2 is pretty useless.
How do I get to drive outside Oauth2?
Please familiarize yourself with OAuth2 before judging the quality of the protocol.
You have to use OAuth2 with the Google Drive API in order to give permission to your application to perform actions on your behalf.
Think of OAuth2 as a "log-in" mechanism for your application into Google's products, like Drive.
Also, familiarize yourself with the Python Quickstart to understand how to do this.

How to authenticate as myself for Google Drive API?

I have not found a satisfactory answer/tutorial for this, but I'm sure it must be out there. My goal is to access Google Drive programmatically using my credentials. A secondary and lower-priority goal is to do this properly and that means using OAuth rather than ClientLogin.
Thus: How do you authenticate with the Google Drive API using your own credentials for your own Google Drive (without creating an application on the Google Developers Console)?
All of the documentation assumes an application, but what I'm writing is merely helper scripts in Python 2.7 for my own benefit.
"How do you authenticate with the Google Drive API using your own credentials for your own Google Drive (without creating an application on the Google Developers Console)?"
You can't. The premise of OAuth is that the user is granting access to the application, and so the application must be registered. In Google's case, that's the API/Cloud Console.
In your case, there is no need to register each application that uses your helper scripts. Just create an app called helper_scripts, embed the client Id in your script source, and then reuse those scripts in as many applications as you like.

Python/Google Apps Script integration

Would it be possible for some type of Python script to check services running on a linux box, and integrate with a google app script, so it would then populate a google doc spreadsheet stating whther a service is running or not ?
Yes. You would need to authorize it the first time and implement oAuth from the script though. I strongly suggest that you switch to the Google Drive API.

Categories

Resources