title: I can't authorize gmail api application in google colab
body: <p>I'm learning gmail api through google colab.</p>
  <p>I'm running the quickstart code in colab and my browser is edge.</p>
  <pre><code>from __future__ import print_function
  import os.path
  from googleapiclient.discovery import build
  from google_auth_oauthlib.flow import InstalledAppFlow
  from google.auth.transport.requests import Request
  from google.oauth2.credentials import Credentials
  
  # If modifying these scopes, delete the file token.json.
  SCOPES = ['https://www.googleapis.com/auth/gmail.readonly']
  
  def main():
      &quot;&quot;&quot;Shows basic usage of the Gmail API.
      Lists the user's Gmail labels.
      &quot;&quot;&quot;
      creds = None
      # The file token.json 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.json'):
          creds = Credentials.from_authorized_user_file('token.json', SCOPES)
      # 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(
                  '/content/drive/MyDrive/Colab Notebooks/credentials for gmail api.json', SCOPES) #使用檔案要上傳
              creds = flow.run_local_server(port=0)
          # Save the credentials for the next run
          with open('token.json', 'w') as token:
              token.write(creds.to_json())
  
      service = build('gmail', 'v1', credentials=creds)
  
      # Call the Gmail API
      results = service.users().labels().list(userId='me').execute()
      labels = results.get('labels', [])
  
      if not labels:
          print('No labels found.')
      else:
          print('Labels:')
          for label in labels:
              print(label['name'])
  
  if __name__ == '__main__':
      main()
  </code></pre>
  <p>after I click the authoritize steps, it pops out
  <a href="https://i.stack.imgur.com/55yFH.png" rel="nofollow noreferrer">it can't find the local host</a>.</p>
  <p>I have no idea what to do, and this quickstart can run successful in jupyter.</p>