Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google API issues from Colab

I'm having difficulty with credentials to make a Google API People call from A Colab notebook. I've tried two different methods. The colab note book is here along with credential files (it's a new account and doesn't contain any sensitive information or scopes)

If I try to access it through an OAuth 2.0 Client IDs, I authorize a redirect URI from colab. I'm asked to login through a Google account, but once I log in through my Google account it opens up a new tab to a website that doesn't exist. The permission process never completes.

Second attempt: if I try to authorize it through a service account credential, I get this error:

ValueError: Client secrets must be for a web or installed app.

I've looked at other answers online but they don't seem to be working. I'm using code directly from Google's quickstart guide. Any help is appreciated. All code and credentials are available in the Colab

like image 220
tom Avatar asked Sep 17 '25 08:09

tom


1 Answers

If you look at the code it is designed for installed applications only thats why you are getting an error using a service account.

flow = InstalledAppFlow.from_client_secrets_file(
                '/content/peopleapipublic-fc597768cf57.json', SCOPES)

As for the "Google account it opens up a new tab to a website that doesn't exist." issue. The issue is due to the change for OOB with desktop aplications Loopback IP address Which states in the docs

To receive the authorization code using this URL, your application must be listening on the local web server.

Unfortunately this change was made before google had time to update all their samples and well every tell us how they want us to create this local web server for use with installed applications.

The authorization code can still be found in the URL bar if that helps any but i cant see that your code is prompting you to to supply the code.

I would post an issue over on google api python clinet and ask them for an updated sample which shows how to create a local webserver with an installed application code. never mind i just did #1813

all in all the issue is unrelated to colab and related to google oauth and installed applications.

like image 92
DaImTo Avatar answered Sep 19 '25 22:09

DaImTo