Running run_local_server in Colab notebook doesn't redirect properly
if not creds or not creds.valid:
if creds and creds.expired and creds.refresh_token:
creds.refresh(Request())
else:
flow = InstalledAppFlow.from_client_secrets_file(
'credentials.json', SCOPES)
creds = flow.run_local_server(port=0)
Trying to run this in a Colab file prints a URL that I need to go to authorise the app. On doing so I'm redirected to http://localhost:58787/?state=blah which can't be reached and the notebook remains listening for a response.
Can you trying removing the port=0 param?
Usually a port is auto assigned I believe.
@sai-sunder-s After removing the port param, I get an error OSError: [Errno 98] Address already in use
I think I understood the problem. Since you are using colab, you are using a browser I am assuming? So colab doesn't have the ability to listen to localhost. That is why it just listens for a response indefinitely I guess.
I have heard of people using pydata-google-auth for notebook scenarios.