Forums

"authorize this application" err on google sheets access

Hello, I try to read a cell from google sheets for my web app. I tried using their code on this site and only changed credentials on the code quickstart

It worked fine on my computer after it asked me to authorize and opened a tab which I followed and I ended up visiting this http://localhost:34030/?state=xqKN0v ... I then uploaded my code to pythonanywhere. I tested the quickstart.py file which connects to my sheet file via Bash console in my virtualenv. It worked fine there as well. But when I started(reloaded my flask app) it is stuck on loading the page. I then checked server.log which shows authorization error(changed my ID in the link below for obvious security reasons)

2019-12-29 16:50:59 Please visit this URL to authorize this application: https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=MYID.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A45821%2F&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fspreadsheets.readonly&state=MYSTATE&access_type=offline
2019-12-29 16:50:59 subprocess 9 exited with code 0

when it can run on my virtualenv how can it not run on the live? It didnt make any sense? Is there a way to bypass this authorization msg?

Thank you

you should setup an app specific password on google.

I can't seem to find app specific pass for google. Could you please elaborate?

Have a look at the Google docs for authorisation: https://developers.google.com/sheets/api/guides/authorizing

I've already read it and created an OAuth client but I can use it on my comp and bash console on pythonanywhere. But the error stays the same when I try to use it on the website

I think that OAuth clients are meant for programs that you're interacting with in consoles (and similarly for interactive JavaScript code) and that you're meant to use an API key when accessing the API from website code. Is there a way to configure the client library you're using to do that rather than using OAuth?

I've managed to get the value I needed following this tutorial https://www.youtube.com/watch?v=vISRn5qFrkM&t with the API key, not with the google's official tutorial but with gspread. Thanks for help anyway