title: How access a website page with Google credentials using python?
body: <p>I have tried access a Google ecosystem page after get credentials. My app will manage Calendar events, using python and Google api. I've got credentials, list events, read summaries, etc. But If I try to access a web page as (with AuthorizedSession class):</p>
  <p><a href="https://calendar.google.com" rel="nofollow noreferrer">https://calendar.google.com</a></p>
  <p>I notice that this page asks for login/password from Google.
  Maybe this task is out of the specified scope. Ideas?</p>
  <p>Thanks in advance!</p>
  <p><strong>Code:</strong></p>
  <pre><code>from googleapiclient.discovery import build
  from google_auth_oauthlib.flow import InstalledAppFlow
  from google.auth.transport.requests import Request
  from google.auth.transport.requests import AuthorizedSession
  import pickle
  import os.path
  import requests
  from pathlib import Path
  
  
  SCOPES = ['https://www.googleapis.com/auth/calendar']
  
  CREDENTIALS_FILE = 'client_secret_123456ABCDEFG.apps.googleusercontent.com.json'
  
  def get_credentials():
     creds = None
     # The file token.pickle stores the user's access and refresh tokens, and is
     # created automatically when the authorization flow completes for the first
     # time.
     if os.path.exists('token.pickle'):
         with open('token.pickle', 'rb') as token:
             creds = pickle.load(token)
     # If there are no (valid) credentials available, let the user log in.
     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_FILE, SCOPES)
             creds = flow.run_local_server(port=0)
  
         # Save the credentials for the next run
         with open('token.pickle', 'wb') as token:
             pickle.dump(creds, token)
  
     return creds
  
  
  
  authed_session = AuthorizedSession(get_credentials())
  
  response = authed_session.request(
      'GET', 'https://calendar.google.com/')
  print(response.status_code)
  ....
  </code></pre>