Forums

How to access Google account in order to use Google API

Hello there, I am using the Google API to shorten URLs in my telegram bot. When I use the bot the first time, I need to access a Google account in order to use that function. On the python console of PythonAnywhere I am not able to do that.

It shows the message Getting https://accounts.google.com/o/oauth2/auth?client_id=xxxxxxxxxxxx-ib0hji without opening a browser page for login or something like that.

How can I login the first time in order to make my bot work?

You should enable two factor auth on google and setup application specific passwords

What do you mean? I am not so into Google API.

Someone can please help me?

Set up this, and then set up this

I already did, what should change? Thank you.

Then you should use the app specific password instead of your google password on PythonAnywhere.

http://prntscr.com/igs2zd

Nothing changed, as you can see.

I'm afraid the documentation that we provide covers our knowledge of how to configure Google auth for use on PythonAnywhere. There's really not a lot we can do to debug your Google configuration.

I'm having the same issues accessing Google APIs from pythonAnywhere. Were you able to resolve this issue?

@zink Have you followed the advice provided above?

Yes. I'm following the following tutorial. I'm successful in running the example on my own machine, but hitting the same issue outlined in this post when running on pythonAnywhere. https://codelabs.developers.google.com/codelabs/gsuite-apis-intro/#0

If the issue is that a browser does not open for you to log in, that is because there is no way for code running on PythonAnywhere to open a browser on your computer. You need to use an authentication mechanism that does not rely on opening a browser to do the authentication. That is why @conrad posted links about how to set App passwords.

What worked for me is: To authorize my app in my desktop and then upload token.pkl and credentials.json to pythonanywhere directory.

That's a good trick -- thanks for sharing!

I can confirm that the best way is to upload the token file into python after following the oAUTH on your desktop