title: Error using google API and OAUTH2 in Python to get user info
body: <p>My web app is successfully going through google's recommended flow to get credentials to query Google Drive API. This works fine. However, when I try to use the same credentials already obtained to get the user's email and name, I get an error.</p>
  
  <p><em>Here I retrieve credentials and query Google Drive API. This works perfectly fine</em></p>
  
  <pre><code>def analyze():
   credentials = getCredentials() 
   drive_service = googleapiclient.discovery.build('drive', 'v3', credentials=credentials)
   theFiles = drive_service.files().list(pageSize=1000,q="trashed=false", fields="files(id,name,modifiedTime, size)").execute() #THIS WORKS
  </code></pre>
  
  <p><em>Right after that, I try to use the SAME CREDENTIALS to get user info, but now it doesn't work</em></p>
  
  <pre><code>oauth2_client = googleapiclient.discovery.build('oauth2','v2',credentials=credentials)
   user_info= oauth2_client.userinfo().get().execute() #THIS FAILS
  givenName = user_info['given_name']
  </code></pre>
  
  <p>Error: https://www.googleapis.com/oauth2/v2/userinfo?alt=json returned "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See <a href="https://developers.google.com/identity/sign-in/web/devconsole-project" rel="nofollow noreferrer">https://developers.google.com/identity/sign-in/web/devconsole-project</a>."></p>
  
  <p><em>SOME OTHER IMPORTANT FUNCTIONS:</em></p>
  
  <pre><code>def getCredentials():
   *Loads credentials from the session.*
   sc = session['credentials'] 
   credentials = google.oauth2.credentials.Credentials(token=sc.get('token'),
   client_id=sc.get('client_id'),
   refresh_token=sc.get('refresh_token'),
   token_uri=sc.get('token_uri'),
   client_secret=sc.get('client_secret'),
   scopes=sc.get('scopes'))
  </code></pre>
  
  <p><em>the credentials are obtained in the callback page:</em></p>
  
  <pre><code>@app.route('/OAcallback')
  def OAcallback():
     flow =google_auth_oauthlib.flow.Flow.from_client_secrets_file('client_id.json', scopes=['https://www.googleapis.com/auth/drive https://www.googleapis.com/auth/userinfo.profile'])
    flow.redirect_uri = return_uri
    authorization_response = request.url
    flow.fetch_token(authorization_response=authorization_response)
    credentials = flow.credentials 
    * Store the credentials in the session.*
    credentials_to_dict(credentials)
  </code></pre>
  
  <p>Please help me understand why my credentials are not working when trying to get user info. What should I change?</p>
  
  <p>Thanks in advance!!!</p>