I am using google_auth_oauthlib.flow
in Python to authorize Google Oauth 2 account.
My code looks like this:
from google_auth_oauthlib.flow import InstalledAppFlow
flow = InstalledAppFlow.from_client_secrets_file(
"client_secret_929791903032.apps.googleusercontent.com.json",
scopes=['profile', 'email'])
flow.run_local_server(open_browser=False)
session = flow.authorized_session()
profile_info = session.get(
'https://www.googleapis.com/userinfo/v2/me').json()
print(profile_info)
Basing on run_local_server()
document, I tried to set open_browser=False
but then Google provided me an URL to authorize, it looks like this https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=929739191032-hpdm8djidqd8o5nqg2gk366efau34ea6q.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2F&scope=profile+email&state=oHJmupijpVH2gJEPqTogVVHIEtbVXcr&access_type=offline
After clicking to the provided link, my browser automatically opened with the UI named Sign in with Google, then I have to sign in manually on the browser.
So my question is how to open the authorization URL without opening browser? I want my code automatically authorize without doing manually.