Google Sheets and Python

Twilio · 1.3M views · 2017 · 6:31

Open on YouTube

Python, Ruby & scripting languagesWeb developmenttutorial

Why Stack Overflow recommends it

Stack Overflow users link it as the standard walkthrough for setting up a Google service account and gspread, and cite it when debugging credential, scope and 403 permission errors.

Recommended by 3 people across 3 different months, 2017 to 2022.

What it is

A short Twilio developer tutorial by Brent Schooley showing how to read and write a Google Sheet from Python using the gspread library. It walks through creating a Google service account, sharing the sheet with it, and authorizing with a JSON key file.

What people said

Strong rec Jimbo Mahoney · 2020-12 · Stack Overflow · on “Struggling to use my own API key with googlesheets4 in shinyapps.io”

OK, pretty sure I've got this working... It was the YouTube video here [this video] that really helped, and made this [LINK] more clear. All I need is a Service Account, which seems to generate a json file that I can upload with my app. i.e. at around 1:03 in the video shows the creation of this service account, then adding that e-mail address (of the Service Account) to the Google Sheet(s) I want to access, this means I can download (using GoogleDrive) and write (using GoogleSheets). The crazy part is that all I need to put in my code is the following: drive_auth(path = ".secrets/client_secret.json") gs4_auth(path = ".secrets/client_secret.json") i.e. those two lines (plus the downloaded json fi

Recommends Peter Bengtsson · 2017-10 · Stack Overflow · on “How would you make an Excel-like user interface with Django?”

Perhaps best thing to do first is to convince someone that the UI doesn't have to be like Excel. Definitely worth consider gspread so that you don't get stuck in a complex relational structure. See [this video] and [LINK]

Recommends Nikita · 2020-07 · Stack Overflow · on “Error 403 google spreadsheets gspread when open in console”

I'm trying to repeat the guide ( [this video] ) - generated client_secrets.json , put it in the DAGs folder (because then I will run the script from airflow) But despite the client secret-still gives the error 403-not enough rights , how can I fix it? import gspread from oauth2client.service_account import ServiceAccountCredentials import pprint scope = [' [LINK] '] creds = ServiceAccountCredentials.from_json_keyfile_name('client_secret.json',scope) client = gspread.authorize(creds) sheet = client.open('Data base').sheet4 result = sheet.get_all_records() print(result)

Cites Walker Frederick · 2017-10 · Stack Overflow · on “Trying to get google sheets data onto my flask web app (where does my .json file go?)”

I'm trying to setup a webapp that will get data from google sheets and display it. I got the idea from this [this video] video by twilio and even got it working locally. Now i'm trying to have it display info into an html doc but can't quite get it to work on my server. I'm pretty sure it has something to do with this... json_data = open(os.path.join(static, "getinfo.json"), "r") scope = [' [LINK] '] creds = ServiceAccountCredentials.from_json_keyfile_name(json_data, scope) client = gspread.authorize(creds) sheet = client.open('hotlistsouthforsyth').sheet1 am I just not putting my "getinfo.json" in the right place? here is the entire code i'm working with... this is my __init __.py from flask imp

Cites Jordan · 2020-03 · Stack Overflow · on “How decipher what the terminal Is saying and possibly offer a solution as to how to get the code to work?”

I am brand new to coding on python as well as coding in general. I am doing a project that takes information from google sheets and displays it in the terminal. It doesn't seem to be working but as a beginner (this is my first project), I have no clue what to do. I used google api to get the credentials. Here is the code I wrote: import gspread from oauth2client.service_account import ServiceAccountCredentials scope = [' [LINK] '] creds = ServiceAccountCredentials.from_json_keyfile_name('sheetsproject-765dzxv233334.json',scope) client = gspread.authorize(creds) sheet = client.open('python test').sheet1 options = sheet.get_all_records() print(options) this is the result in the terminal: Trace

Cites Shahrear Bin Amin · 2020-08 · Stack Overflow · on “RefreshError while trying to access spreadsheet from python”

I was trying to access my spreadsheet GetHookedTest from python following this [this video] tutorial. I've added service account successfully and here is my credentials. Shared by sheet with test@gethooked.iam.gserviceaccount.com { "type": "service_account", "project_id": "gethooked", "private_key_id": "aaaaaabbbbbaaaabbbbaaaaa", "private_key": "Private Key here", "client_email": "test@gethooked.iam.gserviceaccount.com", "client_id": "454454554", "auth_uri": " [LINK] ", "token_uri": " [LINK] ", "auth_provider_x509_cert_url": " [LINK] ", "client_x509_cert_url": " [LINK] " } import gspread from oauth2client.service_account import ServiceAccountCredentials import pprint scope = [" [LINK] ", ' [LINK]

Cites Andrewncf · 2022-08 · Stack Overflow · on “Display Google Drive Image In RShiny Using Service Account”

Feel like I might be missing something here. I am looking to display images from my google drive in a shiny app using the url. I am planning on accessing the images from my drive using a service account. The simple code I have for this is below. The file id is left blank in the url here. library(shiny) library(tidyverse) library(googledrive) drive_auth(path = "client-secret.json") ui <- fluidPage( h4("Embedded image"), uiOutput("img") ) server <- function(input, output, session) { output$img <- renderUI({ tags$img(src = " [LINK] #image_id# ") }) } shinyApp(ui, server) The link that I am using is fine if I make it public; however due to security issues, I thought I could access a private link