code: def GitHub_login(*, username=None, password=None, OTP=None, headers=None):
      
      if not username:
          username = input("What is your GitHub username? ")
  
      if not password:
          password = getpass("Enter the GitHub password for {username}: ".format(username=username))
  
      headers = headers or {}
  
      if OTP:
          headers['X-GitHub-OTP'] = OTP
  
      auth = HTTPBasicAuth(username, password)
  
      r = requests.get('https://api.github.com/', auth=auth, headers=headers)
      if r.status_code == 401:
          two_factor = r.headers.get('X-GitHub-OTP')
          if two_factor:
              if OTP:
                  print(red("Invalid authentication code"))
              # For SMS, we have to make a fake request (that will fail without
              # the OTP) to get GitHub to send it. See https://github.com/drdoctr/doctr/pull/203
              auth_header = base64.urlsafe_b64encode(bytes(username + ':' + password, 'utf8')).decode()
              login_kwargs = {'auth': None, 'headers': {'Authorization': 'Basic {}'.format(auth_header)}}
              try:
                  generate_GitHub_token(**login_kwargs)
              except (requests.exceptions.HTTPError, GitHubError):
                  pass
              print("A two-factor authentication code is required:", two_factor.split(';')[1].strip())
              OTP = input("Authentication code: ")
              return GitHub_login(username=username, password=password, OTP=OTP, headers=headers)
  
          raise AuthenticationFailed("invalid username or password")
  
      GitHub_raise_for_status(r)
      return {'auth': auth, 'headers': headers}
docs: Login to GitHub.
  
      If no username, password, or OTP (2-factor authentication code) are
      provided, they will be requested from the command line.
  
      Returns a dict of kwargs that can be passed to functions that require
      authenticated connections to GitHub.